Not signed in (Sign In)

Discussion Tag Cloud

Categories

Vanilla 1.1.9 is a product of Lussumo. More Information: Documentation, Community Support.

    •  
      CommentAuthorPhyter
    • CommentTimeJan 12th 2014 edited
     
    Let's script a streaming onboard music file!

    Difficulty level: Medium

    What you'll need:
    - NoLimits 2
    - Notepad ++ or similar IDE
    - A .OGG music file (Audacity is a free audio tracker that exports NL2 compatible .OGG files).

    Description: The NoLimits 2 scripting API features methods for attaching streaming audio to specific trains on any coaster in your park. Everything happens in onInit(), the default starting method that is triggered when the script is run. We simply need handles for the streamed sound file, the coaster, and to know how many trains there are in the coaster so that we can assign the handle to each. Let's see how that's done...


    import com.nolimitscoaster.*;

    // OnBoardAudio script by Kevin Stone
    //
    // 1. Place your .ogg file in the same directory as your park file.
    // 2. Change "mymusic.ogg" to your music file.
    // 3. Change "My Coaster" to the name of the coaster you want the music to play on.
    // 4. Save this file as onboardaudio.nlvm
    // 5. Attach the script file to the coaster in the Coaster Properties dialog.
    //
    // This is a simple script so streamed sound will start playing at the same time for all trains.
    // It is most useful for generic looping audio.

    public class onboardaudio extends Script
    {
    private static final String filename = "mymusic.ogg";
    private static final String coastername = "My Coaster";

    Train train;
    Coaster coaster;

    public bool onInit()
    {
    // Get handle for streamed sound.
    StreamedSound mysound = StreamedSound.loadFromFile(filename);
    if (mysound == null)
    {
    System.err.println("The specified file '" + filename + "' was not found.");
    return false;
    }

    // Get handle for coaster.
    coaster = sim.getCoaster(coastername);
    if (coaster == null)
    {
    System.err.println("The specified coaster '" + coastername + "' was not found.");
    return false;
    }

    // Attach the streamed sound to all trains on the coaster.
    int traincount = coaster.getTrainCount();
    for(int i=0; i<=traincount-1; i++)
    {
    train = coaster.getTrainAt(i);
    train.setOnboardStreamedSound(mysound);
    }

    mysound.playLoop();

    return true;
    }
    }


    Steps for setup:

    STEP 1: Open Notepad++ (or other code editor).

    STEP 2: Create a new file, then Copy and Paste the code above.

    STEP 3: Place your .OGG music file in the same folder as your park file.

    STEP 4: In the code, change "mymusic.ogg" to the name of your music file.

    STEP 5: In the code, change "My Coaster" to the name of the roller coaster you want the music on.

    STEP 6: Save the file as " onboardaudio .nlvm".
    Note: The file name is also the class name. If you wish to change the file name to something different then you also need to change the class name where the code states, "public class onboardaudio extends Script".

    STEP 7: Unfreeze your coaster.

    STEP 8: Open Coaster Properties.

    STEP 9: Click on the Scripts tab.

    STEP 10: Click Add, and attach the script to the coaster.

    Save and PLAY! :D
    •  
      CommentAuthordjd711
    • CommentTimeJan 12th 2014
     
    What would I need to tweak here to have an audio file play in the station each time the train leaves?
    • CommentAuthormrcobra92
    • CommentTimeJan 13th 2014
     
    Thank you! I am wondering the same thing the person above me is though.
    •  
      CommentAuthorllamaboy
    • CommentTimeJan 13th 2014
     
    Thanks Phyter!
    •  
      CommentAuthorgeforcefan
    • CommentTimeJan 13th 2014 edited
     
    Posted By: djd711What would I need to tweak here to have an audio file play in the station each time the train leaves?


    sound.nlvm:

    import com.nolimitscoaster.*;

    public class sound extends Script {
    private static final String sCoastername = "MyCoaster";
    Coaster cMyCoaster;

    public bool onInit() {
    cMyCoaster = sim.getCoaster(sCoastername);
    TrackTrigger tTrainLeaveStationTrigger = cMyCoaster.getTrackTrigger("PlayMusic");

    if(tTrainLeaveStationTrigger == null) {
    System.err.println("Trigger not found");
    return false;
    }

    TrackTriggerListener tTriggerListener = new soundTrigger();
    tTrainLeaveStationTrigger.addTrackTriggerListener(tTriggerListener);

    return true;
    }
    }


    soundTrigger.nlvm:

    import com.nolimitscoaster.*;
    import nlvm.math3d.*;

    public class soundTrigger extends Script implements TrackTriggerListener {
    private static final String sSoundFile = "sound.ogg";
    StaticSound sSound;

    public soundTrigger() {
    sSound = StaticSound.loadFromFile(sSoundFile, 0);
    if(sSound == null) {
    System.err.println("Sound file not found");
    return;
    }
    sSound.setEnvironmentMode(StaticSound.E_ENVMODE_LOCAL);
    sSound.setPosition(new Vector3f(0.0f, 15.0f, -10.0f));
    sSound.setGain(10.0f);
    }

    public void onTrainEntering(TrackTrigger trigger, Train train) {
    sSound.play();
    }

    public void onTrainLeaving(TrackTrigger trigger, Train train) {
    }
    }


    just tweak (new Vector3f(x, y, z)) to the position, where the sound "should be".
    Dont forget to create a trigger labeled "PlayMusic" (for example right after leaving the station)

    sSound.setPosition(new Vector3f(0.0f, 15.0f, -10.0f));

    you also have to tweak (change MyCoaster to the Name of your coaster):

    private static final String sCoastername = "MyCoaster";

    and the audio file....

    private static final String sSoundFile = "sound.ogg";

    Have phun.
    • CommentAuthormrcobra92
    • CommentTimeJan 13th 2014 edited
     
    Thanks, but am I meant to add both of those nlvm files to the coaster? When I do I get an error that says "Trigger not Found" please help, thanks.
    •  
      CommentAuthorgeforcefan
    • CommentTimeJan 13th 2014
     
    Because:

    Posted By: geforcefanDont forget to create a trigger labeled "PlayMusic" (for example right after leaving the station)
    • CommentAuthormrcobra92
    • CommentTimeJan 13th 2014 edited
     
    Posted By: geforcefanBecause:

    Posted By: geforcefanDont forget to create a trigger labeled "PlayMusic" (for example right after leaving the station)

    In which file?
    •  
      CommentAuthorgeforcefan
    • CommentTimeJan 13th 2014 edited
     
    Okay... let me explain...

    sound.nlvm and soundTrigger.nlvm should be saved in your *.nl2park directory.
    Add these both scripts into your coaster (Pyther already explained that)

    Create a trigger in the NoLimits Editor, where the sound should be triggered, if the train reaches the trigger.

    make the changes in the code I mentioned above.

    (Please check HTML instead of Text as your comment format)
    •  
      CommentAuthorXpress
    • CommentTimeJan 13th 2014
     
    I keep on getting the error "Not a valid Class name" when I click OK after selecting the script file...
    • CommentAuthormrcobra92
    • CommentTimeJan 13th 2014
     
    Ah, thank you, I got it working!
    •  
      CommentAuthordjd711
    • CommentTimeJan 13th 2014 edited
     
    I got the scripts to work however not quite to the effect I was after. The train always triggers the sound however that means it also triggers the sound when the train comes back in to the station which I don't want. I need the sound to be triggered each time the train lifts into the flying position so that the sound bite can be heard just before you leave the station.

    Is that possible?
    •  
      CommentAuthorHZGarfield
    • CommentTimeJan 13th 2014
     
    Got it ~ Next I want to learn is how to attach a music on a 3ds
    •  
      CommentAuthorgeforcefan
    • CommentTimeJan 13th 2014
     
    Question:

    public final Section getSection(String name)

    Is always returning null. Is there any bugs?
    • CommentAuthorgronji2004
    • CommentTimeJan 13th 2014
     
    geforcefan

    Thanks for the script. I too am getting the trigger not found error, even though ive placed a trigger called PlayMusic on my track where i want the sound to be played, and I've edited the location (XYZ) and still getting the message.

    Im after a basic 321 GO GO Go on my launch section haha:)
    •  
      CommentAuthorAussieMine
    • CommentTimeJan 13th 2014
     
    Here is a question, what if I wanted to recreate, lets say the Beast, at Kings Island. On the lift hill, there is an Audio that says 'remain seated through the entire ride, please keep hands inside the car at all times' and it has a bit of a background music to it. What would I do so it plays like, lets say 3 times on the lift hill?
    • CommentAuthorAIex
    • CommentTimeJan 13th 2014 edited
     
    geforecefan, What about on-board audio after I hit the trigger, so that it only plays in the train that just passed the trigger, and not in the others?

    Would you know how to do that?

    And could you also hear it in fly view? because the script from phyter is only hearable when you are in ride view.

    Edit: Could it also be triggered by dispatching? instead of passing a trigger?
    •  
      CommentAuthorgeforcefan
    • CommentTimeJan 13th 2014
     
    Posted By: AIexgeforecefan, What about on-board audio after I hit the trigger, so that it only plays in the train that just passed the trigger, and not in the others?

    Would you know how to do that?

    And could you also hear it in fly view? because the script from phyter is only hearable when you are in ride view.


    I have to check the abbilities of the API, I think Pyther is more invoved (so ask him :D), since he is a part of the NL Team.
  1.  
    How exactly would I make a script so that a coaster comes to a stop on a brake for a few seconds and then is launched backwards?
  2.  
    Thanks for the scripts! Works perfectly!
    •  
      CommentAuthorPhyter
    • CommentTimeJan 13th 2014 edited
     
    Patience guys. lol I still work an 8-5 regular job and will only be able to answer questions in the evening. Also even though I'm a dev I'm just the texture artist and still very much a novice myself with the Java-like syntax of NoLimits script.

    I'll do my best to answer your questions when I have the time, but you can help ourselves by reading the class overview in the help files. You can open them in a regular internet browser for more convenient access.

    I'm going to be doing a series of these tutorials. I can incorporate alot of your requests in those.
    •  
      CommentAuthorgeforcefan
    • CommentTimeJan 13th 2014 edited
     
    Posted By: AIexgeforecefan, What about on-board audio after I hit the trigger, so that it only plays in the train that just passed the trigger, and not in the others?

    Would you know how to do that?

    And could you also hear it in fly view? because the script from phyter is only hearable when you are in ride view.

    Edit: Could it also be triggered by dispatching? instead of passing a trigger?


    Aaaaand....

    onBoardSound.nlvm

    import com.nolimitscoaster.*;
    import nlvm.util.*;

    public class onBoardSound extends Script {
    private static final String sCoastername = "myCoaster";
    private static final String sOnBoardSoundTriggerName = "OnBoardMusic";
    Coaster cMyCoaster;

    Vector triggerListeners;

    public bool onInit() {
    cMyCoaster = sim.getCoaster(sCoastername);
    if(cMyCoaster == null) {
    System.err.println("Coaster " + sCoastername + " not found");
    return false;
    }

    TrackTrigger tOnBoardSoundTrigger = cMyCoaster.getTrackTrigger(sOnBoardSoundTriggerName);
    if(tOnBoardSoundTrigger == null) {
    System.err.println("Trigger " + sOnBoardSoundTriggerName + " not found");
    return false;
    }

    int numTrains = cMyCoaster.getTrainCount();
    triggerListeners = new Vector(numTrains);

    for(int i = 0; i < numTrains; i++) {
    onBoardSoundTrigger trigger = new onBoardSoundTrigger();
    trigger.setTrain(cMyCoaster.getTrainAt(i));
    triggerListeners.addElement(trigger);

    tOnBoardSoundTrigger.addTrackTriggerListener(trigger);
    }

    return true;
    }

    public void onNextFrame(float tick) {
    for(int i = 0; i < triggerListeners.size(); i++) {
    onBoardSoundTrigger trigger = (onBoardSoundTrigger) triggerListeners.elementAt(i);
    trigger.updatePosition();
    }
    }
    }


    onBoardSoundTrigger.nlvm:

    import com.nolimitscoaster.*;
    import nlvm.math3d.*;

    public class onBoardSoundTrigger extends Script implements TrackTriggerListener {
    private static final String sSoundFile = "onBoardSound.ogg";
    StaticSound sSound;
    Train tCurrentTrain;

    Vector3f vFrontOut;
    Vector3f vTopOut;
    Vector3f vRightOut;
    Vector3f vPosOut;

    public onBoardSoundTrigger() {
    sSound = StaticSound.loadFromFile(sSoundFile, 0);
    if(sSound == null) {
    System.err.println("Sound file not found");
    return;
    }
    sSound.setEnvironmentMode(StaticSound.E_ENVMODE_LOCAL);
    sSound.setGain(5.0f);

    vFrontOut = new Vector3f(0.0f, 0.0f, 0.0f);
    vTopOut = new Vector3f(0.0f, 0.0f, 0.0f);
    vRightOut = new Vector3f(0.0f, 0.0f, 0.0f);
    vPosOut = new Vector3f(0.0f, 0.0f, 0.0f);
    }

    public void setTrain(Train _train) {
    tCurrentTrain = _train;
    }

    public void onTrainEntering(TrackTrigger trigger, Train train) {
    if(train == tCurrentTrain) sSound.play();
    }

    public void onTrainLeaving(TrackTrigger trigger, Train train) {
    }

    public void updatePosition() {
    if(tCurrentTrain == null) return;
    tCurrentTrain.getCarOrientationAndPosition(0, vFrontOut, vTopOut, vRightOut, vPosOut);
    sSound.setPosition(vPosOut);
    }
    }


    Tweak:


    private static final String sCoastername = "myCoaster";
    private static final String sOnBoardSoundTriggerName = "OnBoardMusic";
    ...
    private static final String sSoundFile = "onBoardSound.ogg";
    • CommentAuthorAIex
    • CommentTimeJan 14th 2014 edited
     
    Excellent work!

    Is it normal that it does play on every train, so when Train 1 passes the trigger in the station, Train 2,3,4,5,6 on the track plays it as well (again)?
  3.  
    Would we be able to do something like the clearance envelope and place it near each train (all of the trains with a different named one), and have triggers for them so that it's train specific?
    •  
      CommentAuthorllamaboy
    • CommentTimeJan 14th 2014
     
    Can you do a advanced scripting tutorial please? Like a tut on how to do a reversing coaster like this:
    http://www.youtube.com/watch?v=xiQKjahZmO8
    • CommentAuthorcalfan10
    • CommentTimeJan 14th 2014
     
    Yes please!^
    •  
      CommentAuthorgeforcefan
    • CommentTimeJan 14th 2014 edited
     
    Posted By: AIexExcellent work!

    Is it normal that it does play on every train, so when Train 1 passes the trigger in the station, Train 2,3,4,5,6 on the track plays it as well (again)?


    Should work independently for each train instance, without playing the sound on another train. Let me check that.

    Edit:

    Unfortunately, one loaded ogg file can only played at once at the same time (is this a bug?).
    The solution is, to create an *.ogg file for each train (onBoardSound0.ogg, onBoardSound1.ogg, onBoardSound2.ogg, ... for n trains)

    I modfied the scripts:

    onBoardSound.nlvm:

    import com.nolimitscoaster.*;
    import nlvm.util.*;

    public class onBoardSound extends Script {
    private static final String sCoastername = "myCoaster";
    private static final String sOnBoardSoundTriggerName = "onBoardMusic";
    private static final String sOnBoardSoundFilename = "onBoardSound";
    Coaster cMyCoaster;

    Vector triggerListeners;

    public bool onInit() {
    cMyCoaster = sim.getCoaster(sCoastername);
    if(cMyCoaster == null) {
    System.err.println("Coaster " + sCoastername + " not found");
    return false;
    }

    TrackTrigger tOnBoardSoundTrigger = cMyCoaster.getTrackTrigger(sOnBoardSoundTriggerName);
    if(tOnBoardSoundTrigger == null) {
    System.err.println("Trigger " + sOnBoardSoundTriggerName + " not found");
    return false;
    }

    int numTrains = cMyCoaster.getTrainCount();
    triggerListeners = new Vector(numTrains);

    for(int i = 0; i < numTrains; i++) {
    onBoardSoundTrigger trigger = new onBoardSoundTrigger();
    trigger.setSound(sOnBoardSoundFilename + i + ".ogg");
    trigger.setTrain(cMyCoaster.getTrainAt(i));
    triggerListeners.addElement(trigger);

    tOnBoardSoundTrigger.addTrackTriggerListener(trigger);
    }

    return true;
    }

    public void onNextFrame(float tick) {
    for(int i = 0; i < triggerListeners.size(); i++) {
    onBoardSoundTrigger trigger = (onBoardSoundTrigger) triggerListeners.elementAt(i);
    trigger.updatePosition();
    }
    }
    }


    onBoardSoundTrigger:

    import com.nolimitscoaster.*;
    import nlvm.math3d.*;

    public class onBoardSoundTrigger implements TrackTriggerListener {
    private String sSoundFile = "onBoardSound";

    StaticSound sSound;
    Train tCurrentTrain;

    Vector3f vFrontOut;
    Vector3f vTopOut;
    Vector3f vRightOut;
    Vector3f vPosOut;

    public onBoardSoundTrigger() {
    vFrontOut = new Vector3f(0.0f, 0.0f, 0.0f);
    vTopOut = new Vector3f(0.0f, 0.0f, 0.0f);
    vRightOut = new Vector3f(0.0f, 0.0f, 0.0f);
    vPosOut = new Vector3f(0.0f, 0.0f, 0.0f);
    }

    public void setSound(String filename) {
    sSound = StaticSound.loadFromFile(filename, 0);
    if(sSound == null) {
    System.err.println("Sound file not found");
    return;
    }
    sSound.setEnvironmentMode(StaticSound.E_ENVMODE_LOCAL);

    sSound.setGain(1.0f);
    }

    public void setTrain(Train _train) {
    tCurrentTrain = _train;
    }

    public void onTrainEntering(TrackTrigger trigger, Train train) {
    if(train == tCurrentTrain && sSound != null) sSound.play();
    }

    public void onTrainLeaving(TrackTrigger trigger, Train train) {
    }

    public void updatePosition() {
    if(tCurrentTrain == null || sSound == null) return;

    tCurrentTrain.getCarOrientationAndPosition(0, vFrontOut, vTopOut, vRightOut, vPosOut);
    sSound.setPosition(vPosOut);
    }
    }


    And again tweak this:

    private static final String sCoastername = "myCoaster";
    private static final String sOnBoardSoundTriggerName = "OnBoardMusic";
    ...
    private static final String sOnBoardSoundFilename = "onBoardSound"; // onBoardSound0.ogg, onBoardSound1.ogg, ...n trains
    • CommentAuthorYPOC
    • CommentTimeJan 14th 2014
     
    I asked this in another thread already but got no response, maybe here's a better place for this question.
    Is it possible to use the classes Section and Block without having the coaster in scripted mode? Or can I still use the automatically generated block operation mode when in scripted mode, so that I don't have to build the whole blocksystem like in the scripted example park? I'd like to tweak only some minor things, but it wouldn't be worth coding the complete blocksystem.
    • CommentAuthorole
    • CommentTimeJan 14th 2014 edited
     
    WARNING: In the examples above, the StaticSound.loadFromFile method is not used correctly. The second parameter is a flags parameter, only StaticSound.FLAG_* values can be used here (using binary OR). Simply use 0 for standard settings. The StaticSound.E_ENVMODE_LOCAL is a EnvMode parameter and cannot be used as the second parameter. It should instead be used for the setEnvironmentMode method. So the correct way to load a file and set the local EnvMode would be:


    ...
    sSound = StaticSound.loadFromFile(filename, 0);
    if(sSound == null) {
    System.err.println("Sound file not found");
    return;
    }
    sSound.setEnvironmentMode(StaticSound.E_ENVMODE_LOCAL);
    ...


    @YPOC: No, it is not possible. I will extend the API at some point when I have a better idea of what features users want.
    •  
      CommentAuthorgeforcefan
    • CommentTimeJan 14th 2014
     
    Posted By: oleWARNING: In the examples above, the StaticSound.loadFromFile method is not used correctly. The second parameter is a flags parameter, only StaticSound.FLAG_* values can be used here (using binary OR). Simply use 0 for standard settings. The StaticSound.E_ENVMODE_LOCAL is a EnvMode parameter and cannot be used as the second parameter. It should instead be used for the setEnvironmentMode method. So the correct way to load a file and set the local EnvMode would be...


    Just changed the code... Thanks for the hint, I missed that.
    • CommentAuthorole
    • CommentTimeJan 14th 2014 edited
     
    Another issue:

    sSound.setGain(3.0f);

    The range of gain values goes from 0...1, so 3.0f does not make much sense. It will internally be clamped to 0..1, so it is not directly a bug.


    Another issue:

    public class onBoardSoundTrigger extends Script implements TrackTriggerListener {...

    It is not directly a bug, but onBoardSoundTrigger is not required to extend from Script...

    public class onBoardSoundTrigger implements TrackTriggerListener {...

    ...should work as well. Only the starting class with the onInit, onNextFrame methods is required to extend from Script.
    •  
      CommentAuthorgeforcefan
    • CommentTimeJan 14th 2014 edited
     
    Posted By: oleAnother issue:
    It is not directly a bug, but onBoardSoundTrigger is not required to extend from Script...


    Yeah, I accidentally added onBoardSoundTrigger.nlvm to the coaster, for this reason I got the message "Exception: onBoardSoundTrigger is not an instance of com.nolimitscoaster.Script", thats why there is "extends Script". I realised, that I dont need to append the script onBoardSoundTrigger.nlvm to the coaster. I also realised, I dont need to extend Script, but I missed that in the post above.
    • CommentAuthorYPOC
    • CommentTimeJan 14th 2014
     
    Thanks for your reply Ole. I'd like to create a cable launch using multiple brake segments where the brakefins extend after the train has travelled over them. Therefore I need to be able to (de-)activate the brakes through scripting.
    Right now I can only make it so that the fins won't extend at all (trim brake) or they'll be deactivated just short of the train (multiple small block brakes).
    • CommentAuthorROLLER97
    • CommentTimeJan 14th 2014 edited
     
    For all those NotePad++ users (like me): I made a so called "User Defined Language" to give the text some pretty markup. I basically took the default java one and added the nl2 things. To install: download the .xml file, and under the tab "Language", select Define your language. Then import the file you downloaded, and restart N++.
    • CommentAuthorAIex
    • CommentTimeJan 14th 2014
     
    Thanks Roller97!

    Devs, Just took a few hours to get the BlockScript to work with one of my tracks, gotta admit scripting all blocks on a coaster with a mix of lifts, stations, brakes, switches and storage is a lot of work haha (and it only needs to be done for the switches, all the rest would work perfectly automated in closed circuit mode). It would be handy if you could just attach a script to a certain piece of track instead of the whole coaster (and having to define everything). For example add a script to a switch to tell it what to do, and add a script to the brake behind the switch what to do and then your done :) Or maybe even better> switching without scripts at all just add a trigger and then in the Switch Track Properties have the ability to link triggers and define what they should do (position 1 or position 2).
    • CommentAuthorPePpO
    • CommentTimeJan 16th 2014
     
    Posted By: ROLLER97For all those NotePad++ users (like me):I made a so called "User Defined Language" to give the text some pretty markup.I basically took the default java one and added the nl2 things. To install: download the .xml file, and under the tab "Language", select Define your language. Then import the file you downloaded, and restart N++.


    nice :-)
    • CommentAuthorcoasterkev
    • CommentTimeJan 17th 2014
     
    sorry for my bad english i´m from germany ;)

    I have all done like the description. when i play this messages came: error C8: Class not found onboardaudio

    in the scripting tab i can´t choose a class so i let it empty.

    what´s the problem?

    thanks :)
    •  
      CommentAuthorPhyter
    • CommentTimeJan 17th 2014 edited
     
    > error C8: Class not found onboardaudio

    It means the file name does not match the file reference set in Coaster Properties -> Scripts -> Script Class. Did you change the file name? If so, you will need to go back into the Script tab in Coaster Properties and select the file again.

    Remember also that the file name has to be exactly the same as the class name. In this case, "onboardaudio.nlvm"...

    public class onboardaudio extends Script
    • CommentAuthorPePpO
    • CommentTimeJan 18th 2014 edited
     
    @Phyter:

    Is there a possibility of an autocompleteoption like in eclipse or other IDE`s?
    This would make scripting so much faster and easyer.
    edit:
    I love the script "language ", exactly like Java :-)
    •  
      CommentAuthorPhyter
    • CommentTimeJan 19th 2014
     
    I'm not a heavy duty programmer. But as far as I know, most generic IDEs with auto-complete or some form of 'intellisense' are not free. jEdit, I recently found out, has a customizable auto-complete feature. But I haven't delved into enough to know if it would be useful. It would be worth checking out though.
    •  
      CommentAuthorMillennium
    • CommentTimeJan 20th 2014
     
    Is there any way to have Station music? I tried using the sound script as well as the trigger/trigger script combo, but none of those worked for me.
    •  
      CommentAuthorPhyter
    • CommentTimeJan 20th 2014
     
    You would code a static sound that loaded with a scenery object and then simply place the object in the station. I am at work right now but will post an example when I get home.
    •  
      CommentAuthorXpress
    • CommentTimeJan 20th 2014
     
    I am still having issues with attaching the audio script to the coaster. I keep on getting the "Not a valid class file." error every time I try to attach the script to the ride. Any ideas?? I've followed Phyters instructions to the T...
    •  
      CommentAuthorPhyter
    • CommentTimeJan 21st 2014 edited
     
    Here is a very simple static sound script for just about any use. Station music, area music, ambient sounds, whatever. Copy and paste the code into a blank text file and save as "staticsound.nlvm". Assign it to any NL2SCO file and place the object in the scene. Change "MyMusic" to your .ogg file. Play with the Distance and Falloff parameters to attenuate the sound to whatever you need it for.


    import com.nolimitscoaster.*;
    import nlvm.math3d.*;

    public class staticsound extends Script
    {
    private SceneObject sco;

    private StaticSound sound;
    private static final float Distance = 3.0f;
    private static final float FallOff = 7.0f;

    public bool onInit()
    {
    sco = sim.getSceneObjectForEntityId(getParentEntityId());

    sound = StaticSound.loadFromFile("MyMusic.ogg", 0);
    if (sound == null)
    {
    System.err.println("Sound file not found");
    return false;
    }

    Vector3f pos = new Vector3f();
    sco.getTranslation(pos);

    sound.setEnvironmentMode(StaticSound.E_ENVMODE_GLOBAL);
    sound.setPosition(pos);
    sound.setDistanceParameters(3.0f, 7.0f);
    sound.setDopplerMode(true);

    sound.playLoop();
    return true;
    }
    }
  4.  
    How can that code be changed in order to play a nonrepeating sound when the train passes a trigger? I tried reading through the help files and I just don't know how to put it together as I'm not a programmer at all... I'm guessing you would use E_ENVMODE_LOCAL instead of global as it won't be extremely loud that the entire park can hear, but once again I have absolutely no clue! :P
    •  
      CommentAuthorDonidia
    • CommentTimeJan 21st 2014
     
    I know this is completely irrelevant, but i'm new and don't know how to make a new thread. But i was wondering how i could make a transfers track automatically switch once it comes onto a certain block? E.g. Like expidition everest... So i could make a coaster go both forwards and backwards. Thanks:)
  5.  
    ..\..\Users\Austin\Documents\com.nolimitscoaster.nolimits2\newpark 6\Sound.nlvm : error C14: Invalid class name or package: expected: Sound in root package, found: sound in root package
    ...1 error(s), 0 warning(s)

    What does this mean?
    •  
      CommentAuthorL Bosch
    • CommentTimeJan 23rd 2014
     
    Sound vs. sound probably. Capital letters.
  6.  
    That's what I thought too, but my sound file is named "Sound.ogg" so I don't know what's going on :(
    •  
      CommentAuthorcheshire
    • CommentTimeJan 23rd 2014
     
    Just a question, where I can found an API for scripting?