Skip to content

All Comments

7641 to 7660 of 19729

Filter comments

The Official Scripting Ask Thread
Scripting

Thanks for the help thimok. I'm having trouble with the reworked code at this line: if(trackTrigger == trackTrigger2){. Just says syntax error. Where did I go wrong?

import com.nolimitscoaster.*;

class TestScript extends Script implements TrackTriggerListener
{
	Coaster coaster;
	Section section;
	TrackTrigger trackTrigger;
	TrackTrigger trackTrigger2;
 
	bool onInit(){
        coaster = sim.getCoasterForEntityId(getParentEntityId());
		trackTrigger = coaster.getTrackTrigger("StationClear");
		trackTrigger2 = coaster.getTrackTrigger("BBlockClear");
        trackTrigger.addTrackTriggerListener(this);
		return true;
    }

    void onNextFrame(float tick) {
	}
		
	public void onTrainEntering
		if(trackTrigger == trackTrigger2){
		System.err.println("Occupy B Block");
		break
		if(trigger == trackTrigger) {
		System.err.println("StationClear");
		break
    }	
}
View comment
The Official Scripting Ask Thread
Scripting

First of all, create a global TrackTrigger variable, under the Coaster coaster and Section section variables. So move the first TrackTrigger trackTrigger to there.
Then in the onInit, you do trackTrigger = coaster.getTrackTrigger("Trigger 1").

Do the same for other tracktriggers, like TrackTrigger trigger2.

Then on the onTrainEntering and onTrainLeaving methods, check which of the triggers has been triggered. You simply do this by: if (trigger == trackTrigger2) { //ACTION }

View comment
The Official Scripting Ask Thread
Scripting

Hello everyone, I'm fairly new to scripting with NL2 and with this type of language so bear with me. I have a successful script that I'm trying add to. Currently it will only acknowledge one track trigger that displays text. I'm trying to add another trigger to this but can't figure it out. Initially I just copy pasted a new section but that failed and I can't figure out how to integrate another trigger and have additional text appear. Whenever I add in a line it just says that line has a syntax error and that's it. Any ideas?

import com.nolimitscoaster.*;

class HelloScript extends Script implements TrackTriggerListener
{
	Coaster coaster;
	Section section;
 
	bool onInit(){
        coaster = sim.getCoasterForEntityId(getParentEntityId());
		TrackTrigger trackTrigger = coaster.getTrackTrigger("Trigger1");
        trackTrigger.addTrackTriggerListener(this);
		return true;
    }

    void onNextFrame(float tick) {
	}
		
	public void onTrainEntering(TrackTrigger trigger, Train train) {
	System.err.println("Occupy B Block");
    }

    public void onTrainLeaving(TrackTrigger trigger, Train train) {
	System.err.println("Clear A Block");
    }
	
}
View comment
7641 to 7660 of 19729