Not signed in (Sign In)

Discussion Tag Cloud

Categories

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

    •  
      CommentAuthorrcth
    • CommentTimeDec 28th 2015
     
    If you need some help, send me a personal message on TP (same username) and I'll try to help you with it.
    • CommentAuthorole
    • CommentTimeDec 30th 2015 edited
     
    I am really annoyed to this bad code again: sSound = StaticSound.loadFromFile(soundFileTrain1, StaticSound.E_ENVMODE_LOCAL);
    I mentioned it a couple of times already that the second parameter cannot be used in this way.

    The second parameter of StaticSound.loadFromFile is a flags parameter and only FLAG_SHARED or FLAG_MUSIC or a bitwise combination is allowed here. Those are special options.

    FLAG_SHARED means that the same sound will be shared among multiple instances of StaticSound (good for simulating multiple speakers of the same sound).
    FLAG_MUSIC means that the sound is a piece of music, this will make the sound to be controlled by the music volume instead of the sound volume slider in the setup.

    Set it to 0 (=default) if you do not want any of that.

    There is no need to have multiple copies of music files for each train if you don't use the FLAG_SHARED flag.
    •  
      CommentAuthorAJClarke0912
    • CommentTimeJan 9th 2016 edited
     
    For everyone unaware, Ole has helped me go back through the old posts in this thread and update them all with the correct lines of code for soundTrigger.nlvm. Everything should be fixed and you should be updating your code from there if you haven't already. Here it is again if you need to see it. Thanks!

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

    public class soundTrigger 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) {
    }
    }
  1.  
    For my One on One I have to put some onride music on each ride. I've got the basic code working and the piece is constantly on loop from the park starting to it being stopped, but I'm a little confused on exactly what code I would need to have the music start once the train dispatches and then not repeat until it is dispatched again. Can anyone help me?

    Also, exactly what code is needed to have music play around the park?
    • CommentAuthoriHack97
    • CommentTimeApr 6th 2016
     
    Is it possible to make a static sound audio script with multiple triggers/music ?
    •  
      CommentAuthorGiftaddict
    • CommentTimeMay 15th 2016
     
    Hi! I'm also interested to do a multiple triggers/music coaster. How difficult it is to add a "stop" trigger to the actual static onboard sound script?

    Thanks!
    •  
      CommentAuthorKG9
    • CommentTimeMay 15th 2016
     
    What about audio surrounding the ride, but not onboard?
    •  
      CommentAuthorNemesisRider
    • CommentTimeSep 17th 2016 edited
     
    Anyone able to help me with this? I have some errors and no sound is played:

    OnboardAudioMultiScript.nlvm:

    import com.nolimitscoaster.*;

    public class OnboardAudioMultiScript extends Script implements TrackTriggerListener
    {
    private static final String soundFile1 = "Soundtrack1.ogg";
    private static final String soundFile2 = "Soundtrack2.ogg";
    private static final String soundFile3 = "Soundtrack3.ogg";
    private static final String soundFile4 = "Soundtrack4.ogg";
    private static final String soundFile5 = "Soundtrack5.ogg";

    private static final String sound1TriggerName = "Sound 1";
    private static final String sound2TriggerName = "Sound 2";
    private static final String sound3TriggerName = "Sound 3";
    private static final String sound4TriggerName = "Sound 4";
    private static final String sound5TriggerName = "Sound 5";

    private TrackTrigger sound1Trig;
    private TrackTrigger sound2Trig;
    private TrackTrigger sound3Trig;
    private TrackTrigger sound4Trig;
    private TrackTrigger sound5Trig;


    public bool onInit()
    {
    Coaster coaster = sim.getCoasterForEntityId(getParentEntityId());

    sound1Trig = coaster.getTrackTrigger(sound1TriggerName);

    sound1Trig.addTrackTriggerListener(this);

    sound2Trig = coaster.getTrackTrigger(sound2TriggerName);

    sound2Trig.addTrackTriggerListener(this);

    sound3Trig = coaster.getTrackTrigger(sound3TriggerName);

    sound3Trig.addTrackTriggerListener(this);

    sound4Trig = coaster.getTrackTrigger(sound4TriggerName);

    sound4Trig.addTrackTriggerListener(this);

    sound5Trig = coaster.getTrackTrigger(sound5TriggerName);

    sound5Trig.addTrackTriggerListener(this);

    return true;
    }


    public void onTrainEntering(TrackTrigger trigger, Train train)
    {

    StreamedSound sound1 = StreamedSound.loadFromFile(soundFile1);
    StreamedSound sound2 = StreamedSound.loadFromFile(soundFile2);
    StreamedSound sound3 = StreamedSound.loadFromFile(soundFile3);
    StreamedSound sound4 = StreamedSound.loadFromFile(soundFile4);
    StreamedSound sound5 = StreamedSound.loadFromFile(soundFile5);

    if (trigger == sound1Trig)
    {
    train.setOnboardStreamedSound(sound1);
    sound1.play();
    }
    else if (trigger == sound2Trig)
    {
    train.setOnboardStreamedSound(sound2);
    sound2.play();
    }
    else if (trigger == sound3Trig)
    {
    train.setOnboardStreamedSound(sound3);
    sound3.play();
    }
    else if (trigger == sound4Trig)
    {
    train.setOnboardStreamedSound(sound4);
    sound4.play();
    }
    else if (trigger == sound3Trig)
    {
    train.setOnboardStreamedSound(sound5);
    sound5.play();
    }



    }

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

    }


    soundTrigger.nlvm:

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

    public class soundTrigger implements TrackTriggerListener {
    private static final String sSoundFile = "onride soundtrack.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(11.62f, 4.92f, -11.2f));
    sSound.setGain(10.0f);
    }

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

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




    Anyone know how to solve this?
    •  
      CommentAuthorYedrimas
    • CommentTimeSep 17th 2016 edited
     
    Check your sounds with this script.
    import com.nolimitscoaster.*;

    public class AudioTest extends Script
    {
    private static final String MySoundFile = "SoundFilde.ogg";

    public bool onInit()
    {
    StreamedSound MySound = StreamedSound.loadFromFile(MySoundFile);
    sim.getCoasterForEntityId(getParentEntityId()).getTrainAt(0).setOnboardStreamedSound(MySound);
    MySound.play();
    return true;
    }
    }


    (You last else if seems wrong, it's (trigger == sound3Trig) instead of (trigger == sound5Trig) I guess ^^)

    EDIT :

    The first error is strange since your script isn't using the soundTrigger class.

    The second error means the trigger named "sound1TriggerName" could not be found on the coaster where the script is attached.
    •  
      CommentAuthorNemesisRider
    • CommentTimeSep 17th 2016 edited
     
    Tried that sound test script



    Something has gone horribly wrong xD
    • CommentAuthorMrRC
    • CommentTimeSep 20th 2016 edited
     
    else if (trigger == sound4Trig)
    {
    train.setOnboardStreamedSound(sound4);
    sound4.play();
    }
    else if (trigger == sound3Trig) =================== change here : else if (trigger == sound5Trig)
    {
    train.setOnboardStreamedSound(sound5);
    sound5.play();
    }


    Staff edit: When you post a script, you can use the < code > < /code> tags so it's easier to read. ;)
  2.  
    ^ I tried this and it didn't work. I've got someone to script it in for me now, so don't worry ;)
    • CommentAuthorMrRC
    • CommentTimeSep 21st 2016
     
    Ok cool, good luck with your project
    • CommentAuthoriHack97
    • CommentTimeSep 23rd 2016 edited
     
    This is a simple onboard static sound that i made myself. You have to make a .nlvm file for each train.





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

    public class onBoardStaticSound extends Script implements TrackTriggerListener
    {
    Train fTrain;
    private int NbTrain;
    private int numtrain = 0;
    private TrackTrigger Trigger1;
    private TrackTrigger Trigger2;
    private static final String sSoundFile1 = "";
    StaticSound sSound1;
    private Vector3f positionSound ;


    public bool onInit(){

    String name;
    Coaster coaster = sim.getCoasterForEntityId(getParentEntityId());
    if (coaster == null){
    System.err.println("Coaster not found");
    return false;
    }

    fTrain = coaster.getTrainAt(numtrain);
    NbTrain = coaster.getTrainCount();
    Trigger1 = coaster.getTrackTrigger("");
    Trigger1.addTrackTriggerListener(this);
    Trigger2 = coaster.getTrackTrigger("");
    Trigger2.addTrackTriggerListener(this);
    sSound1 = StaticSound.loadFromFile(sSoundFile1, StaticSound.FLAG_MUSIC);
    return true;
    }

    public void onNextFrame(float tick){

    Vector3f fo = new Vector3f(0.0f, 0.0f, 0.0f);
    Vector3f to = new Vector3f(0.0f, 0.0f, 0.0f);
    Vector3f ro = new Vector3f(0.0f, 0.0f, 0.0f);
    Vector3f po = new Vector3f(0.0f, 0.0f, 0.0f);

    fTrain.getCarOrientationAndPosition(1, fo, to, ro, po);
    positionSound = po;

    sSound1.setPosition(positionSound);
    sSound1.setGain(300.0f);
    }

    public void onTrainEntering(TrackTrigger trigger, Train train){
    if(trigger == Trigger1){
    sSound1.setDopplerMode(false);
    if (train.getSpeed() > 0)
    {
    if(train == fTrain){
    sSound1.setGain(50.0f);
    sSound1.setDistanceParameters(15.0f, 15.0f);
    sSound1.play();}
    }
    }

    if (trigger == Trigger2){

    if (train.getSpeed() > 0)
    {
    if(train == fTrain){
    sSound1.stopFaded(0.01f);}
    }
    }

    }

    public void onTrainLeaving(TrackTrigger trigger, Train train){} }
    •  
      CommentAuthorMillennium
    • CommentTimeSep 25th 2016
     
    I'm attempting to use the "station music code":

    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;
    }
    }


    and I keep receiving an error:
    Exception: NullPointerException
    at public bool staticsound.onInit() in line 24
    at public final void com.nolimitscoaster.Script.run()

    for
    sco.getTranslation(pos);

    Anyone have any ideas why?
    •  
      CommentAuthorYedrimas
    • CommentTimeSep 25th 2016
     
    ^Is your script attached to a SceneObject (not a coaster) ?
    • CommentAuthorPopFilms
    • CommentTimeOct 22nd 2016
     
    I was trying to use the station/offride audio script for my coaster and I don't know how to assign it to a NL2SCO object.