Skip to content

NL2 Ask Thread

251 to 275 of 369

How can I assign a number to a train. How can I read that number in a script?
To make different trains do different things when they pass over a trigger.

Posted February 1, 2022· Edited February 1, 2022

MrRC posted on January 29th, 2022

How can I assign a number to a train. How can I read that number in a script?
To make different trains do different things when they pass over a trigger.

The idea is this:

Demo:

import com.nolimitscoaster.*;
import nlvm.lang.System;

public class TriggerDemoDetectTrain extends Script implements TrackTriggerListener {
    // assumes you have not more than 4 trains on the coaster!
    private static final int[] ASSIGNED_TRAIN_NUMBERS = {
            1, // Train 1
            2, // Train 2
            3, // Train 3
            42 // Train 4
    };

    private TrackTrigger trigger;
    private Coaster coaster;
    private int numberOfTrains;


    public bool onInit() {
        coaster = sim.getCoasterForEntityId(getParentEntityId());
        numberOfTrains = coaster.getTrainCount();

        TrackTrigger trigger = coaster.getTrackTrigger("enter your trigger name here");
        trigger.addTrackTriggerListener(this);
        return false;
    }

    public void onTrainEntering(TrackTrigger trigger, Train train) {
        for (int i = 0; i < numberOfTrains; ++i) {
            if (train == coaster.getTrainAt(i)) {
                int assignedNumber = ASSIGNED_TRAIN_NUMBERS[i];
                System.out.println("Train with assigned number " + assignedNumber + " entered the trigger.");
                return;
            }
        }
    }

    public void onTrainLeaving(TrackTrigger trigger, Train train) {

    }
}

Inverted Steel posted on February 1st, 2022

I've been trying to figure this out but part of my train (is supposed to) emit bright LED's. Does anyone know how I can replicate light being emitted from the train in a texture PNG file (I've got a texture file for the Inverted Wing which I'm using for my textures)? I've tried in GIMP but it's just a dull colour plastered on the surface as opposed to emitting light.

Or do I need to try something else (I'm trying to avoid attaching objects to the train). I don't really know much about textures (I make all my 3D models etc. without them and then I just use my imagination and ngl textures just seems really difficult and alien to me) but the LEDs are something that I think will look really good on my current WIP coaster (especially at night time).

I would also like to ask what modelling software is used by NL2 users (to create realistic looking trains for example and then subsequently to animate them) and any scripting advice or places to learn this which is relevant to NL2.

As far as I know there is no emission texture channel assigned for the NL2 trains, threfore you would have to model your own 3d model piece that fits onto the train and attach it and use the nl2mat editor to assign the emission color on your own textured model.

For modeling I strongly recommend using blender - it's not only free of money but free software and very powerful.
Some helpful quickstart might be this YouTube Playlist

For scripting try this: How to start with Scripting?

Posted February 1, 2022· Edited February 1, 2022

EDIT : Nevermind , i got it working , tnx

@bestdani. I assume i have to attach the demo script to the excisting coaster in my park ?

Hi,
can anyone help me to write a script for a track triggered door?
Sorry if I write something wrong because I am from Germany!
I hope anyone can help me.

bestdani posted on February 1st, 2022

The idea is this:

Demo:

import com.nolimitscoaster.*;
import nlvm.lang.System;

public class TriggerDemoDetectTrain extends Script implements TrackTriggerListener {
    // assumes you have not more than 4 trains on the coaster!
    private static final int[] ASSIGNED_TRAIN_NUMBERS = {
            1, // Train 1
            2, // Train 2
            3, // Train 3
            42 // Train 4
    };

    private TrackTrigger trigger;
    private Coaster coaster;
    private int numberOfTrains;


    public bool onInit() {
        coaster = sim.getCoasterForEntityId(getParentEntityId());
        numberOfTrains = coaster.getTrainCount();

        TrackTrigger trigger = coaster.getTrackTrigger("enter your trigger name here");
        trigger.addTrackTriggerListener(this);
        return false;
    }

    public void onTrainEntering(TrackTrigger trigger, Train train) {
        for (int i = 0; i < numberOfTrains; ++i) {
            if (train == coaster.getTrainAt(i)) {
                int assignedNumber = ASSIGNED_TRAIN_NUMBERS[i];
                System.out.println("Train with assigned number " + assignedNumber + " entered the trigger.");
                return;
            }
        }
    }

    public void onTrainLeaving(TrackTrigger trigger, Train train) {

    }
}

Ok. So I'm working a project where each train has a set of headlights. I've gotten it to the point where I can get them to turn off and on with the trigger. I'm hoping to have only the headlights on the train out on the course is on and so far All the headlights turn on. Is there a way to run 3 copies of the trigger script and have the trains operate independent of each other? If not It will be ok to run it n 1 train mode but i was hoping for at least 2 trains. The ride only has 3 trains.

I added the script above to the coaster and then added the triggered lights to the headlights. Any thoughts?

Posted April 27, 2022· Edited April 27, 2022

Is there an easier way to get the cut out for the terrain so the tunnel i imported actually looks like a tunnel? I used the virtual tunnel for the rest of the tunnel but the entry and exit are giving me an headache.

Posted April 27, 2022· Edited April 27, 2022

@ RedLimitsCoasters :

Make a model in Google Sketchup and place it at the entrance and exit of the tunnel. In the middle your Virtual tunnel, works perfectly for me.
Problem solved.

MrRC posted on April 27th, 2022

@ RedLimitsCoasters :

Make a model in Google Sketchup and place it at the entrance and exit of the tunnel. In the middle your Virtual tunnel, works perfectly for me.
Problem solved.

That's what I already did. But there are no square virtual tunnels so there is always some terrain showing

@ AceDFE19

Yes, thats possible

Only in combo with a custom train, like i did in this video :

First i made this :

Later on, i incorporated it to this :

Hi guys, does anyone know if there's any plugin that allows to an NL2 element to be built in reverse? Like the last node becoming the first one and so on?

Hey everyone, I'm looking for a train set for NL2. Train as in Steam Train, Dollywood Express, KI Railroad type train. I feel like I've seen one floating around before but I haven't been able to find one. If you google No Limits 2 Train all you get are results for custom coaster trains, which is awesome, but has made the search super hard lol. Thank in advanced!

251 to 275 of 369