Board index Roller Coaster Games NoLimits Coaster 2 NoLimits Coaster 2 Scripting Scripting - Attaching lights to a coaster train

Scripting - Attaching lights to a coaster train

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

Posts: 34
Points on hand: 2,223.00 Points
Location: USA
After messing with scripting and the NL2SCO editor, I was able to attach some lights to a suspended coaster train. Here are a couple videos to show the final result. I have some notes about how I did it below the videos.

This is (a slightly outdated version of) the coaster in the day time. Notice the lights turn on once it enters the tunnel.

This is (again, a slightly outdated version of) the coaster at night. The lights turn on the same time the lift lights turn on.

The script is in charge of getting the position of the coaster train's first bogie (wheel structure) every frame and moving the lights to the location of the bogie. Each NL2SCO file (one for left and one for right) has the correct position offset and rotation to get the lights where I wanted them. The script also checks to see if it should turn the lights on or off. If it is nighttime or if the train is underground, the script turns the lights on. Otherwise it turns the lights off.

I borrowed parts of the script from Phyter's script to attach an object to a train car (posted somewhere on this forum), and I used parts of the NL2 built-in white spot light for the 3ds file, textures, and NL2MAT (unsure what it really does or if I'm really using it).

Here are a few things I learned from the process:

1. With the current state of the scripting API, it is impossible to attach the lights to swinging part of the suspended coaster car. There are only functions to get the position/orientation of the fixed part of the car or the position/orientation of the bogies (part of the train that the wheels attach to). The lights are currently attached to the first bogie.

2. It is impossible to make a flash light that points in the same direction as the user's view. There is an API function for the user's view's position, but not the orientation.

3. The lights on the lifts turn on when the sun's elevation is 0.4 radians or below. (sim.getCurSunElevation() <= 0.40)

4. You can't tell if a track section has a tunnel or not with the current API.

5. You can, however, tell if a position is underground by using the getTerrainHeight function (I used sim.getTerrainHeight(pos.x,pos.z) > pos.y - 2.0f)

The track (Swinging Light) is posted on the exchange if you would like to check it out or reuse the lights in your own track.

Return to NoLimits Coaster 2 Scripting


  • Related topics
    Last post