Skip to content

The Official Scripting Ask Thread

26 to 50 of 347

Is it possible to script a Vekoma Flying coaster like the plan was by Stingray. So the car flips on the lifthill and not at the station?

@ Ward, so far as i know thats not possible, the command to tilt the seats is imbedded into the program, before u could choose that point.

I'm curious. Together with a friend I'm working on a dive coaster and I want to do custom block scripts for it. However, I'm not sure if it's possible to script the hold segment before the drop. Does anyone know?

^ There's actually an option in the chain lift settings to do a Holding Brake:

It come preset with the accurate speed, and hold time, for a B&M dive coaster. Just check the box and you're good to go.

I know I know. I meant that we are probably going to do a scripted blockscript coaster and I wanted to know if that option works with scripted blocks as well. :)

Posted March 25, 2018· Edited March 25, 2018

EDIT : Got it working

@ Yedrimas (Doombuggy Script) I have an error "[Master] No buggy registered, script canceled" i'm lost here.

If you do not have basic programming skills, get them by learning the basics of a language that supports object orientation - this is not really that hard as some might think it is.

Java is very similar to the NL2 scripting language, but other languages that share the same concepts also work, do some researches which one you might want to use to get the basics, especially if you might want to apply your skills to other field's in the future. If it wouldn't be about NL2 scripting I would recommend Python for almost every beginner, but since it's a bit different in syntax and also some concepts. If NL2 scripting is your primary goal, I think Java would be the best option.
There are good free learning resources everywhere in the internet, like videos, free e-books and also some official guides for some of these languages.

The language details do not matter that much: It's not worth getting into details except for the conceptual ones, NL2's NLVM scripting language uses it's own standard library (Scripting API in the NL2 help), so in the end you have to "learn" the specials about NL2's language and the Scripting API usage anyway. I think after getting basic programming skills it's the best to learn from reading the manual (of course) and learning from the examples that come with NL2 as well as other existing scripts.

Semi-Crosspost:

Is it possible to script for the following?:

-I want my coaster to slow at the top of the lift from 6 to 3-4mph (It's a tilt coaster and I want it to hit the tilt track slower.)
[Addition: Or set the chain to idle with a train on it; how would I do that?]

-I want this same coaster to activate a particular trim brake only in these two cases-

A train is occupying the next block
The coaster is in e-stop
(The trim is immediately before the MCBR and in real life would activate only if the MCBR needed to stop the train, so the rather short MCBR could bring the train to a more comfortable, safe stop with a margin for error. In all other cases, the train is allowed through the MCBR "full-open." At the moment, the trim is basically cosmetic and the MCBR has to slam the train to a stop in an emergency, which in real life would probably be frowned upon for safety reasons, so I added an extra brake caliper on the slope up to the MCBR.)
Because the trim brake caliper's minimum speed is very high, it will not activate during normal operation, but in e-stop it still doesn't go off.

I do know some basic programming in a few languages, although I haven't used C (which AFAIK is the language NL2 Script is most similar to out of the ones I know) in almost a year.

You have to bring your coaster to the scripted operation mode first, there's a helper package in the script park of NL2 for doing that with just little effort and the scripted coaster in this park is a good example / template for modifying the script for your own usage.

After it runs in scripted operation mode you can start to control your brake and lift sections using own conditions. Have a look at the Scripting API reference for what options you have to control the sections.

To get control of the sections you have to query them from the coaster object like it is done for the special tracks in the example script park coaster script.

Then you basically just have some simple if conditions for controlling the sections, like

//pseudo code

if (blockIsOccupied){
    trimBrakeSection.setBrakesOn();
}

if(trainIsAtLiftTop){
    liftSection.setLiftFwdIdleOn();
}

You can use the "internal triggers" of the sections (also look in the API for the options you have) straight forward like that or you can use track tirggers, which require to use callbacks in your script. There are other example scripts delivered with NL2 that show you how to use it if you need that instead.

bestdani posted on April 24th, 2018

You have to bring your coaster to the scripted operation mode first, there's a helper package in the script park of NL2 for doing that with just little effort and the scripted coaster in this park is a good example / template for modifying the script for your own usage.

After it runs in scripted operation mode you can start to control your brake and lift sections using own conditions. Have a look at the Scripting API reference for what options you have to control the sections.

To get control of the sections you have to query them from the coaster object like it is done for the special tracks in the example script park coaster script.

Then you basically just have some simple if conditions for controlling the sections, like

//pseudo code

if (blockIsOccupied){
    trimBrakeSection.setBrakesOn();
}

if(trainIsAtLiftTop){
    liftSection.setLiftFwdIdleOn();
}

You can use the "internal triggers" of the sections (also look in the API for the options you have) straight forward like that or you can use track tirggers, which require to use callbacks in your script. There are other example scripts delivered with NL2 that show you how to use it if you need that instead.

Thank you! Yeah, I've started to modify the Cursing Mommy script to run my coaster in a way similar to the default full circuit mode, and then I'll try to screw with the custom stuff.

Has anybody had any success using track triggers in scripts? I've tried creating a listener using triggerVar.addTrackTriggerListener(listenerVar), but my onTrainEntering and onTrainLeaving methods aren't called, and I get two exceptions, which appear to occur when the train is entering and leaving the trigger.

Exception: NullPointerException
                at public void com.nolimitscoaster.TrackTrigger.onNextFrame()
                at void com.nolimitscoaster.Simulator.nextFrame()

I'm not familiar with Java interfaces, so I'm not quite sure what I'm doing wrong.

Posted May 1, 2018· Edited May 1, 2018

I've checked that the right coaster is loaded into c (Coaster), and double checked that the trigger name in the script matches that in the Trigger Settings dialogue. I'm not getting any error from the assignment, though the two listener variables appear to be null after running the following code.

public bool onInit() {
                c = sim.getCoasterAt(0);

                triggerOn = c.getTrackTrigger("LightOn");
                triggerOff = c.getTrackTrigger("LightOff");

                triggerOn.addTrackTriggerListener(listenerOn);
                triggerOff.addTrackTriggerListener(listenerOff);

                return true;
        }

edit: the trigger variables return an address when printed, the listeners return null.

From the text I guess that you have added the onTrain... methods directly in your script class, what's important is that you explicitly declare that this class does so (and that's as far as I know the whole point of Java's / NLVM's interfaces).

If you do that with your script:

import com.nolimitscoaster.*;

public class MyScriptWithTriggers extends Script implements TrackTriggerListener{
    //not sure if you already used the implements clause for your script
    //...
	
    public void onTrainEntering(TrackTrigger trigger, Train train){
        //...
    }
    public void onTrainLeaving(TrackTrigger trigger, Train train){
        //...
    }
    
    public bool onInit(){
        c = sim.getCoasterAt(0);

        triggerOn = c.getTrackTrigger("LightOn");
        triggerOff = c.getTrackTrigger("LightOff");
        
        //here's the difference
        triggerOn.addTrackTriggerListener(this);
        triggerOff.addTrackTriggerListener(this);
        
        return true;
    }
}

As far as I know the whole point of Java's / NLVM's interfaces is to have an explicit way to declare which methods are guaranteed in a class to be existing and callbacks like that are a important way for this.

Can someone help me here?
I'm using TCM's RMC Trains and the zero car will not attach, accompanied by this message:

26 to 50 of 347