Skip to content

The Official Scripting Ask Thread

226 to 250 of 347

MrRC posted on January 21st, 2020

@postyork

I don't think that's not possible. I have more than FIVE years of experience with scripting.

Sorry, do you mean you think it is or it isn't possible?

I've only been scripting for a few months so I bet you know better than me!

Posted January 26, 2020· Edited January 26, 2020

use a zero distance switch to allow the wireframe train to switch over to the launch track.

the black line shows the path of the wireframe train. the fake train(custom train shown in colour) would stop where the two tracks cross over, it would then have a simple rotation animation so it turns to face the direction of launch then proceed.

Amazing animation

after the wireframe train is in position, the custom train would then attach back and continue the layout.
I hope its understandable, i would actually make it all work buts its real late.

Posted January 26, 2020· Edited January 26, 2020

Yes i understand what u mean. U can make it turn with tracktriggers using the rotation script

Posted February 17, 2020· Edited February 17, 2020

Hey everyone!

I've recently started to figure out how scripting works, but on my current project to test my scripting abilities, I've run into a problem:
I want to launch a train out of the Station into the first Block of the Track, but despite the Train visibally entering the next block, the Number of Trains on the Station Block never goes to 0, so I cannot pull the next Train from the Unloading into the Loading Station.

This is the current Block Layout and the first Train clears the red Block after going over the Hill of the Lift-Launch, but even if the Train reaches the end of the orange Block, the function

stationLaunchBlock.getNumberOfTrainsOnBlock();

still returns 1.

Does anyone know how to fix this issue or did I assign the different Blocks wrong during initialization?
My current code can be found here: https://github.com/NavaParo/NoLimitsScripting/blob/master/RunCoaster.nlvm
And this image gives more information about my namings of different Track parts:

If you need more information about the project, pease ask.
Thanks a million already in advance!

Edit: Fixed the link to the code

I don't have enough time to go through your entire code at this moment, but one thing immediately struck my eye: The use of Magic Numbers

You refer to blockstates as numbers (state 1, state 2, state 3). Try to work with constants to give these numbers a name, e.g. a meaning.
public static final int STATE_BLOCK_FREE = 0;
public static final int STATE_BLOCK_APPROACHING = 1;
public static final int STATE_BLOCK_LEAVING = 2;
...

Then you can do something like:
block.registerState(STATE_BLOCK_FREE,"Free",block.LAMP_OFF);
if(nextBlock.getState() == STATE_BLOCK_FREE)

By the way, line 68, you're ending the if with a semicolon instead, which shouldn't be there:
if(block.getState() != 2);
{
block.setState(0);
}

Posted February 17, 2020· Edited February 17, 2020

Nava posted on February 17th, 2020
[...] or did I assign the different Blocks wrong during initialization?

Looks indeed like this is the issue, in line 164 you set

stationLaunchBlock = coaster.getBlock("StationUnload");

I guess you meant the block "StationLoad" there instead ;-)

I am trying to make a script that causes ride errors and stops the train along the course. I have figure out how to do this on a coaster that has a lift but I am having some trouble on a launched coaster. My idea is to use a track trigger to decide when to stop the train. The issue is that I have not found a way to use tack triggers in a block script and don't know if it's possible to link two scrips together. My thinking was to somehow activate the Emergency Stop using a script but so far all I have found is isEmergencyStop which only returns if the E-Stop is or isn't activated, Is there a way to make the emergency stop active? I was also thinking of maybe somehow thinking that F8 on the keyboard was pressed without having to press it. I am relatively new to scripting so I apologize if there is a simple solution I am overlooking.

there is unfortunately no way to use a script to set the E-stop, the only way i could think of doing it would be to set the brakes on and the transports off

226 to 250 of 347