Skip to content

The Official Scripting Ask Thread

126 to 150 of 347
Posted October 16, 2018· Edited October 16, 2018

thank you so much for this there is 2 warnings but i think i know what they are, and it finally works when i left click the light turns on which is almost what i want

import nlvm.math3d.*;
import nlvm.lang.Math;

doesn't need to be there for now

Posted October 17, 2018· Edited October 17, 2018

^^ But that's a different situation then, all users that have the default settings would still have to press the mouse button. The script should rather query if the Next Train Button (which is T by default) has been pressed instead of the Action Button then, if you really need to have it on the Next Train Button.

But I'd recommend to use the dedicated Action Button for those situations, since it is made for that and has no potential side effects.

Posted October 17, 2018· Edited October 17, 2018

this i where im confused since im not really sure what to do, im not sure but,would it would be something like identify the button, state what its purpose is and then add it to the script, in the place of the left click.

also i was thinking about it would it be better to be a light that turns on and stays on with one press and then press it again and it turns off??
or am i making it a tad to complicated

im making a thirteen style drop track and i have successfully made the drop by tilting a transfertrack, i know what needs to hapen but i was just going to ask if it is possible,

have the attach to script so i can attach the sco cars to the train, have them go round the track, and then before it gets to the entrance of the drop have a trigger that tells to sco car to detach from the train and follow a pre scripted movement so it looks like its droping, then at the base exit of the drop have another trigger that ends the pre scripted movement and attach back to the train.

there would have to be a lot of timings to be worked out but would it work??

anyone that wants to learn scripting nolimits2 just released a entire section on tutorials what things do and how they work, it can be found in( Help->ScriptingAPI-> introduction->Class overview)
this will definitely get you started with scripting

Hi! Does anyone know how to script to change the lift motor sound to get it loud from the motor position itself?
I've played around with the Custom Coaster Noises script but the sound comes from the area that coaster passed by not from the motor position.

You can use Linear motor instead of chain or booster wheels, the only noise you have then is from the moving train. You can lower the speed of the train to make it harder to hear.

^^ When you mean a completely custom sound placed by a script and with the lift section sound set to silent, changing the position of the sound in the script should be just one line or a few more to have a more comfortable result.

You can use the newly added area sound object to have a static sound at this position already, a sound that reacts to the lift speed is also possible with just very basic programming techniques.

Posted November 6, 2018· Edited November 6, 2018

Hi there, have anyone of you scripted the "Giant Swinging Disc (Giant Frisbee)" and "Gyro Drop" into manual mode? What i mean is that it could be more than cool to script all the rides to be manually controlled and make a "Real Park Operator Experience" since the physics are extremely realistic. I don't know myself how to do this but as i spoke to the NL2 Creators they said that all the flat rides are freely available for modification. Is there a chance that some of you talented scripters out there could do just so? It shouldn't be difficult to do, Or you could help me and tell me how to do it cause i don't have any clue about JavaScripting.

It's not possible to quickly tell one how to do it by himself, you have to learn quite sophisticated programming techniques (the NLVM - NL2 Scripting language - is a full high level programming language) first to be able to do it, which I'd expect to take at least a few month of training.

I'm not sure if it would be a great idea to try to do it with the default flat rides at all, while it is technically possible, it's rather effortful to do it, since one does not have the comfortable access to the internal rides, since the models cannot be used outside of NL2 in a 3d application to inspect them properly (or did I missed something?), except for some demo rides.

Maybe it's better to hope for official updates that implement the manual control mode like the one for the two new rides, as it is implemented in the updated rides now.

If you want to enjoy fully controlable rides in NL2 with a lot of extras, I have participated in a project where this can be done, but these rides are highly detailed and therefore not suitable for placement into random maps, therefore these are just there to be played in encrypted packages: steam workshop or the project's website (you can also download single ride packages from there).

Bestdani, just wondering how you got the gates to open and close, mine arent working even though they have the keyframed animation i made in blender on them

I'm working on a proof-of-concept for a trackless darkride which works like this:

I have 3 little cube objects called BP-1, BP-2 etc. in sequence (BP meaning BlockPoint). The script should gather all the BPs and create objects for them. Then it should calculate the path between them, and create an object for the RS (RideSection) with the beginning BP and ending BP. The last BP connects with the first BP.

This is working as expected, except I want to output the results for all the RideSections. I get a NullPointerException when I want to access .getBegin() on a RideSection instance. I'm not really sure why at this point.

RideController.nlvm: https://pastebin.com/qtV2uBuT
BlockPoint.nlvm: https://pastebin.com/xa6W9M4Q
RideSection.nlvm: https://pastebin.com/yZe6Nmgv

Thanks in advance for your help :)

I guess the problem is that you increment the rsPosition index in line 49 already, therefore you never set rideSections[0] to a non null value in RideController.

Wonder if anyone's yet made a script where the lift slows down if the next block is occupied, and then when the next block is clear, the lift speeds up. I know I've seen people request that as a feature but IDK if that would be possible to script.

Posted December 11, 2018· Edited December 11, 2018

Hi! I'm trying to write a script that will prompt the time it takes one specific coaster train from one trigger to the next one. This will help me to time effects on a video that I am trying to create... more info on that project soon!

The script underneath is attached to my coaster. The error that I am getting is "An abstract method from a base class or interface is not implemented:

"public abstract void com.nolimitscosater.TrackTrigger.onTrainEntering(com.nolimitscoaster.TrackTrigger.com.nolimitscoaster.Train)"
"public abstract void com.nolimitscosater.TrackTrigger.onTrainLeaving(com.nolimitscoaster.TrackTrigger.com.nolimitscoaster.Train)"

When I try to change my public void -> public abstract void I get the following error:

"Abstract method has body"

If someone would be willing to help me out, that would be greatly appreciated!

Excuse me for the mess that is the script underneath here, I'm not too familiar with the NL2 scripting language...

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

public class TimerScript extends Script implements TrackTriggerListener
{
	private static final String scriptName = "TimerScript";
	private TrackTrigger startTimer;
	private TrackTrigger readoutTimer;
	private TrackTrigger endTimer;
	private double startTime;
	private double readoutTimeElapsed;
	private double readoutTime;
	private double endTimeElapsed;
	private double endTime;
	private double totalTime;

	public bool onInit() 
	{
		Coaster coaster = sim.getCoasterForEntityId(getParentEntityId());
			if(coaster == null) 
			{
				System.err.println("Attach this script to a coaster in the coaster settings tab");
				return false;
			}
			else
			{
				startTimer.addTrackTriggerListener(this);
				readoutTimer.addTrackTriggerListener(this);
				endTimer.addTrackTriggerListener(this);
				System.out.println("Triggers initiated");
				System.out.println(scriptName + "will start timing coaster" + coaster);
			}
			return true;
	}

	public void OnTrainEntering(TrackTrigger trigger, Train train)
	{
		if (trigger == startTimer)
		{
			startTime = sim.getCurAbsSimulationTimeSec();
			System.out.println("Start Time: " + startTime);
		}
		else if (trigger == readoutTimer)
		{
			readoutTimeElapsed = sim.getCurAbsSimulationTimeSec();
			readoutTime = readoutTimeElapsed - startTime;
			System.out.println("Readout time: " + readoutTime);
		}	
		else if (trigger == endTimer)
		{
			endTimeElapsed = sim.getCurAbsSimulationTimeSec();
			endTime = endTimeElapsed - readoutTime;
			totalTime = endTimeElapsed - startTime;
			System.out.println("TIMING RESULTS");
			System.out.println("==============");
			System.out.println(" Start time recording " + startTime);
			System.out.println(" Readout time recording " + readoutTimeElapsed);
			System.out.println(" End time recording " + endTimeElapsed);
			System.out.println(" Total time " + totalTime);
			System.out.println(" Zone 1 timing" + readoutTime);
			System.out.println(" Zone 2 timing" + endTime);
			System.out.println(" === End of timing === ");
		}
	}
	
	public void OnTrainLeaving(TrackTrigger trigger, Train train)
	{
	}		
}
126 to 150 of 347