Board index Roller Coaster Games NoLimits Coaster 2 NoLimits Coaster 2 Scripting Randomizer Script

Randomizer Script

Post your Nolimits 2 scripts here! Also any discussion regarding scription for NoLimits Coaster 2 should be placed in this forum

Post February 14th, 2014, 12:21 am
TTD03 User avatar
True Addicts
True Addicts

Posts: 7306
Points on hand: 738.00 Points
Bank: 111,265.11 Points
So someone on a different site made a track with a script that randomizes which side of the track you go on.
Here's a link to just the script part of it.
Credit to that user who made it.
http://pastebin.com/tKCCpXAE

Edit: Track is uploaded here now
http://www.coastercrazy.com/track_exchange/detail/20175

If someone has the time or wants to dive into this to figure out how the randomizer was implemented, feel free, I'm sure many would benefit from it.

Tetsu: Welcome
Last edited by TTD03 on February 16th, 2014, 2:43 am, edited 1 time in total.

Post February 14th, 2014, 12:38 am

Posts: 151
Points on hand: 374.00 Points
Location: Virginia, USA
Lines 140-151 is the randomizer.

        trackSide = Math.random();               
        if (trackSide <= 0.5)
        {
            trackSide = 0;
            //System.out.println("Left");
        }
        else
        {
            trackSide = 1;
            //System.out.println("Right");
        }


Math.random() generates a random number between 0 and 1. He then decides which side it goes to based on that, <= 0.5 goes to the left station, > 0.5 goes right. He sets a value to tell other functions where to set the Transfer Table.

Note: He uses this code verbatim in several places in the script. A better way would be to create a method for it and call the method when you want to use it instead of having the same code cluttering up the script several times.

Post February 16th, 2014, 2:25 am

Posts: 3
Points on hand: 1,678.00 Points
Location: South Brisbane, QLD, Australia

This is my script, based on the tutorial posted by coasterlover420 over on TPR/NL-Exchange.

I'm not really much of a scripter, so most of the script has been hacked together from what I do know...I've now implemented this as a method in my script:

private void setTrackSide()
   {
      trackSide = Math.random();
      
      if (trackSide <= 0.5)
         {
            trackSide = 0;
            //System.out.println("Left");
         }
      else
         {
            trackSide = 1;
            //System.out.println("Right");
         }
   }


Any other suggestions for improvements? I've just uploaded the coaster that this script relates to to the exchange here - http://www.coastercrazy.com/track_exchange/detail/20175

Post February 16th, 2014, 2:42 am
TTD03 User avatar
True Addicts
True Addicts

Posts: 7306
Points on hand: 738.00 Points
Bank: 111,265.11 Points
Ah I see, I do notice however that the script tends to switch the trains to the left track more than the right. Not sure why though, as the randomizer is perfectly 50-50 between them. Just lucky left every time I guess?

Post February 16th, 2014, 3:28 am

Posts: 3
Points on hand: 1,678.00 Points
Location: South Brisbane, QLD, Australia

Thats the nature of being random! In my experience, it has been selecting right more than left, but this could just be perception - as you say, it should be a 50/50 split...

Post February 16th, 2014, 4:03 am
TTD03 User avatar
True Addicts
True Addicts

Posts: 7306
Points on hand: 738.00 Points
Bank: 111,265.11 Points
Yea I guess its really how the randomizer is feeling that day, its gonna be more to the left for some, and more to the right for others.

Post February 22nd, 2014, 2:38 pm

Posts: 673
Points on hand: 209.00 Points
Bank: 3,034.00 Points
Location: I am everywhere O____O
Is it possible to use a randomizer script modified to randomly toggle spinning car releases? Anyone know of a tutorial that might help get me started?

Post February 22nd, 2014, 5:25 pm
TTD03 User avatar
True Addicts
True Addicts

Posts: 7306
Points on hand: 738.00 Points
Bank: 111,265.11 Points
Originally posted by LuckyK

Is it possible to use a randomizer script modified to randomly toggle spinning car releases? Anyone know of a tutorial that might help get me started?

It might, but it would definitely have to be modified a bit.

Post February 22nd, 2014, 6:29 pm

Posts: 151
Points on hand: 374.00 Points
Location: Virginia, USA
AFAIK, you can't. Triggers are non-modifiable, always on, single state switches. This means they can't be turned on and off at run-time, and they only do one thing.

Once set in the editor, spinning triggers will always turn the spinning on, or they will always turn the spinning off. There is nothing documented in the API that will allow you to fiddle with their settings. You can listen for when the train passes a trigger, but you can't stop the trigger from being flipped.

There is also no way to turn the spinning on or off at run-time, so setting a blank trigger and using that to turn spinning on or off isn't possible either.


Return to NoLimits Coaster 2 Scripting

 


  • Related topics
    Replies
    Views
    Last post