Skip to content

The Official Scripting Ask Thread

51 to 75 of 347

How do I add a brake sound? I have an invisible brake segment but still want the brake sound there. What do I do to make the sound engage when a train passes?

I would like to add a trigger to have the sounds of brakes engage when a train reaches a certain point, but I don't even know where to begin. I can't begin to comprehend scripting (I am not a smart person), and the help files don't offer any details or suggestions. Is it as simple as adding a trigger and finding the brake sound and somehow putting that there? Or do I have to download files and try that?

As far as I know you can only turn it to red (with the side effect of also making it automatically pop up) by using the System.err instead of the System.out PrintStream.

I just can't figure this problem out. I'm creating a block script for my roller coaster. After the station, there's a transfer section, on which the train has a complete stop. In real life, this is about 30 seconds for a "on ride pre-show". For testing purposes (I'm not gonna wait half a minute each time), I set the complete stop in the coaster settings to 3 seconds. Unfortunately, the train only stops for a frame and then continues again.

The variable waitUntil is the current simulation time plus the wait time the brake is configured to. For debugging purposes, I have added a console log line, which outputs the current simulation time, the configured brake time and the two added together. When leaving the block, I have another output which shows the time it leaves the block.

As you can see, the train leaves the block immediately after coming to a stop. The console log "Waiting" is only displayed once, so it's leaving the block after just one frame.

I just can't figure out where it goes wrong. Line 435 is clear. The current simulation time needs to be greater or equal to the waitUntil variable (sim time when entering the block + brake time), which isn't the case when it leaves the block so early.

Does anyone know where I went wrong?

You should try to print waitUntil when the train is leaving.
Also check if you're not creating (or updating) waitUntil in a function, making it back to 0 (or another random value) each frame.

Cheers. Don't know how I didn't figure that out but it's working fine now!

Another question: I cannot find separate methods for the chain drop segment action. Moving the chain and stopping it when the train is past the trigger, doesn't help because the train still falls immediately. It's actually the last piece to the entire block scirpt now. :p

Posted June 6, 2018· Edited June 6, 2018

Alright here comes a wall of pictures and text...

https://gyazo.com/4f1b1f1f16126d0cf037f90deff7e576

This bogie is made to function exactly like the rocket coaster bogies in Nolimits 2. The problem with this is that conventional scripts to attach objects to bogies would not work, including that of CCC2 and other pre-made attachment scripts.

This issue with these is that the script functions off of one central rotation point that works like a ball and socket, with the whole bogie model rotating off of this point.

The Rocket coaster however, along with many other styles both in Nolimits 2 and real life feature multiple separate rotation points in this case 2 for horizontal rotation and two for vertical, as far as i can tell this is simply not possible (or very difficult) to replicate via scripting.

https://gyazo.com/83b95e79b9fd11972bd0e05d70ba4097https://gyazo.com/996599cfc9f5ceafdd3469a151b9cc84

As you can see by these horrifically bad paint drawings, the bogies need to rotate in the same places as the nl2 trains to function correctly and not become misaligned during turns and vertical curves. This issue is especially apparent when you attempt to attach these to a train using "normal" methods.

https://gyazo.com/ebb24882d60806a6ad4db06111453898

As you can see, instead of being locked to the two attachment points, the bogie rotates around an invisible spot in the center of the train, resulting in significant deviation from where they should normally be, especially during tight turns.

https://gyazo.com/3413f13aa3d1dc53bcbe9b8ea0a586fe

This is also true for curves on the vertical axis, in reality, the green section would remain aligned to the chassis of the car while the orange section would rotate around its centerpoint (bolt location).

Now i have seen scripted bogies that do function correctly, a good example being the new gen Intamin LSM trains made by Thecodemaster, however these too, are not without issue. While the articulation does work correctly it bugs out whenever the track goes beyond vertical. This is apparently not possible to fix at the moment due to vectors freaking out when the vertical point is reached.

So, my question is, is there ANY way that this bogie could be scripted to emulate the movements of the rocket coaster bogies, would it require separate scripts and attachments for each individual section or does something within the scripting API of NL2 need to change to make this work at all? Is there any way for the scripting engine to track the position of each element of the wheel assembly and attach each relevant part of the model to it? The bogie i made is designed to perfectly match each rotation point of the default train.

Any insight into this would be awesome.

P.S while im at it, an option in NL2 to hide individual parts of the trains when frozen, for example "freeze only bogies" or "hide seats" would be amazing for making semi custom trains very easily ;)

Posted June 7, 2018· Edited June 7, 2018

As you can see on this picture, NL2 is obviously also not calculating an independent rotation for the left and right rail bogie. Instead it seems to fake the movement by just using the center rail orientation and the boogies are just offset to the left and right. That's exactly what you should do with your bogies, I think the only thing that would have to be preset is the offset since there's no chance to get it from the API automatically as far as I can see.

So you will definitely have to separate them and only apply the rotation to each individual bogie. It's up to you if you want to keep these as separate objects or use a single train object with the bogies as elements and so on. Of course the final script design will be dependent on which solution you want to use.

Actually I'm wondering what the vertical issue is you are talking about. At least when using matrices directly I never saw something like this happening and I'm wondering how this should happen when using the Vectors.

Which environment does everyone use to script for NL2? I'm getting a bit annoyed by the "auto complete" from Notepad++. I love IntelliJ, but we can't use the NL2 language in it unfortunately.

Posted June 7, 2018· Edited June 7, 2018

I use IntelliJ IDEA ;-)
When you put the Scripting-API into an importable module for example it can help very much when creating NL2 scripts. Of course everything else like refactoring own classes and method suggestions also work great.

The only thing is that because NLVM does use bool for example instead of boolean IDEA will show you lots of errors so it's not possible to spot real ones that quickly (related to this). A workaround would be maybe some conversion tool, so that you can type in Java with booleans for example and "transpile" it to NLVM, but I got used to ignore all the NLVM language's related errors. I think it works great.

Demo of it in action:

By the way the Scripting API can be just copied without taking very much care, I did it manually just stripping everything away from the tables in the documentation, so there are missing semicolons and stuff all over the Classes in the Scripting API module, but IDEA deals well with this when suggesting auto completions. I also considered creating a "API-Doc to API module" conversion tool that does this automatically, but for now it was quicker to just creating it manually and maintaining it when the API is updated.

@ Bestdani, i did install the porgram , when i start it, it comes with an error :

and then the program closes it self.

51 to 75 of 347