The Official Scripting Ask Thread
I just discovered the com.nolimitscoaster.StreamedVideo class, in which it seems to be possible to show a video in NL2. However, the API documentation isn't very clear and I literally found zero results on this subject.
I guess you have to script where you want to show the video and on what object, size, etc. But this class does not support any method like this.
Has anyone figured this out yet?
The update news

and the com.nolimitscoaster.SceneObject API documentation

give pointers to where to look and in general a better idea how to use it.
Thank you :) Didn't even notice that method in the SceneObject class!
I'm looking for Turntable track element
EDIT : I modified the doorscript and made a sliding door script of it and bypassed the action button part
I'm looking for : Automatic opening door when approaching the door (no action button) script.
For the automatic door opening when player approaches, you may use bestdani's Instant Animations with the Proximity Trigger :)
Coaster Blast, tnx for your comment. But i got it fixed.
Is there an event fired when someone clicks the 'reset' button on the NL2 control panel of a ride? My block states disappear after I click that button and breaks the ride.
This is how the normal operating state should be:


Did I miss something that re-initializes the blocks after a reset? I noticed this problem occurs in all of my custom block scripts, but not in the default NL2 scripted coaster shipped with the program. So there should be something.
A good question, I would check if one of the on...Mode methods are being called or even called in a certain sequence.
When clicking reset, it triggers the onAutoMode() method. In here I only set the initial block state (FREE if no train on block or WAIT_FOR_CLEAR/IN_STATION when train on block). I tried to also call the function registerBlockStates(block) on the different blocks to re-register the states, however the problem persists. Maybe something else is triggered after the onAutoMode() call, but I'm not sure which.
Not sure if this is the right place to ask, or if it's a no go to even ask it but can someone help me with a script for the following idea I have?
I want it to go through the track normally until it passes the brake and the switch, it goes up the spike and travels backwards for a little bit, when it's going backwards it goes up a hill it previously passed too and goes forward again, but this time I want the brake to be activated to stop the train, then the switch to move and the train to move forward again towards a small piece of track to the station.
Is it possible? Can somebody help me with a script, I tried it with the block blocks but It doesn't want to make sense to me. And scripting looks like Japanese to me which I also don't speak.
Feel free to DM me if you wanna help.

Tim, check your PM
I'm having problems with streamedvideo. I have 4 camera's on one screen. I did this by having 4 faces, each with their own material in Blender. I created 4 nl2mat files. First one has texture unit 0 as "video stream slot #0". Second material has texture unit 0 as "no texture" and unit 1 as "video stream slot #1". This is done for the third and forth material as well (with 4th material having unit 0, 1, 2 no texture, unit 3 "video stream slot #3").
I created a class which loads a streamedvideo and then plays it on one of the texture unit slots. It seems to work half. I hear the video audio, but it doesn't show the video itself. Instead, it shows a yellow face, as shown on the image below:


So, somehow it doesn't show the real video. Does anyone know the problem?
Sometimes you just come to a realisation when laying in bed... In this case, dumb me forgot to UV unwrap the faces. Now (with some rotation because the camera was showing upside down first) it seems to work!
However... only for texture slot 0. Slots 1, 2 and 3 don't work. I do not hear audio and the only thing I see is a gray square on the first camera, as shown in the image below.

Maybe I need to lay in my bed again, but I do not have any clue on this problem so far. The materials seem well-defined to me. Anyone has an idea?
Hi,
Can someone give me a download of the triple launch script from Bestdani? I can't download it on steam because my NL2 is bought by the official site.
Huge thanks in advance!
@ Sasquatch787
U can use this from Bestdani Custom Logic Builder
https://www.dropbox.com/s/fb8lj11261yqgbe/Custom Block Logic Builder (No Videos).nl2pkg?dl=0
And is there a link for Bestdani's 95 degrees? With working doors, stuffs
@ Sasquatch787 I think u mean 97 degrees park :
https://www.dropbox.com/sh/6i02ddi0vls2jy0/AABP-5nt0I2mp7AFRJKaEZjSa?dl=0
Having a little trouble with playing a sound attached to an object. This object+script worked in a brand new park, but when copying all the files over to a number of my other projects, the sound cannot be heard. There is no error produced. Any ideas?
[Code moved below]
You probably messed up some file path somewhere, if it used to work.
Edit: You are returning false at the end of onInit. Return true instead. If you return false it will "stop the initialization and abort execution" (according to the official NL2 Scripting Docs). Not sure if that fixes it but it might be the reason why it doesn't do anything and also doesn't throw an error.
I have had some strange sound behavior in the past like this and I guess NLVM's garbage collector might be too aggressive with the sound objects sometimes that aren't used anymore further in the code and therefore seems to kill them although they play some sound (I have heard sounds playing and all of a sudden stop in some cases).
This is for example a case where I (successfully) tried to use a vector as a workaround to keep an instance alive that the GC does not kill:

Still getting the same result
import com.nolimitscoaster.SceneObject;
import com.nolimitscoaster.StaticSound;
import nlvm.math3d.Vector3f;
import nlvm.util.Vector;
public class SoundSphere extends com.nolimitscoaster.Script
{
protected StaticSound sound;
private final Vector preventGarbageCollecting = new Vector();
private static float getRangeFromScoScale(SceneObject sco)
{
Vector3f scale = new Vector3f(0, 0, 0);
sco.getScale(scale);
return scale.x * 10.0f;
}
public final bool onInit()
{
// Get the object
int parentID = getParentEntityId();
SceneObject sco = sim.getSceneObjectForEntityId(parentID);
// Load the sound file
int flags = StaticSound.FLAG_SHARED;
sound = StaticSound.loadFromResourceId("sound", flags);
if(sound == null)
{
System.err.println("Could not load sound!");
System.throwRuntimeException("Resource not found");
}
// Set additional parameters
sound.setDistanceParameters(getRangeFromScoScale(sco), 10.0f);
sound.setEnvironmentMode(StaticSound.E_ENVMODE_GLOBAL);
sound.setGain(1.0f);
preventGarbageCollecting.addElement(sound);
// Loop the sound
sound.playLoop();
return true;
}
}
Maybe try to make it static as well. And / or also try to create some empty onNextFrame method that does "something" (like just set some variable to some value or so). In my case (it's the sound setup helper script) I also returned false from onInit in some cases and with the static collector it kept alive. But maybe it just worked since the VM is still running, I have no idea if NL2 stops it when nothing is running or not.
If the error persists and cannot be resolved, contact the NL2 support, Ole agreed when I contacted them as I noticed some behavior like this even further before in another case, that it indeed might be the GC that kills it, but since I was the only person (back then) and found a workaround no measures have been taken on the NLVM engine side.
Maybe also try to add some onNextFrame code and just do something cheap like
if(sound != null){
}
there.
So it would be wrong of me to assume that sounds are placed relative to their object
sound.setPosition(sco.getTranslation());
Thanks for your help anway :)

besdani, you are the best, that is exactly what I was looking for! Thank you