Board index Roller Coaster Games NoLimits Coaster 2 NoLimits Coaster 2 Scripting Wrong Sound Playing From Script

Wrong Sound Playing From Script

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

Post August 7th, 2015, 7:47 pm
TTD03 User avatar
True Addicts
True Addicts

Posts: 7306
Points on hand: 738.00 Points
Bank: 111,265.11 Points
Hey there, I am trying to play 2 sounds using a triggers on the track.

I am using geforcefan's sound.nlvm and soundTrigger.nlvm files to do this.

The first sound and trigger work perfectly, but when I setup the second sound, and create sounddown.nlvm and soundTriggerDown.nlvm, it plays the first sound file instead of the second.

Not sure what I've done wrong as everything seems correct and NL2 is showing no errors.

Audio 1:

sound.nlvm


import com.nolimitscoaster.*;

public class sound extends Script {
   private static final String sCoastername = "Kingda Ka";
   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 = "KingdaKaRoarUp.ogg";
   StaticSound sSound;

   public soundTrigger() {
      sSound = StaticSound.loadFromFile(sSoundFile, StaticSound.E_ENVMODE_LOCAL);
      if(sSound == null) {
         System.err.println("Sound file not found");
         return;
      }
      sSound.setPosition(new Vector3f(0.0807f, 20.476f, -285.73f));
      sSound.setGain(100.0f);
   }

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


Audio 2:

sounddown.nlvm
import com.nolimitscoaster.*;

public class sounddown extends Script {
   private static final String sCoastername = "Kingda Ka";
   Coaster cMyCoaster;

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

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

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

      return true;
   }
}

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

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

   public soundTriggerDown() {
      sSound = StaticSound.loadFromFile(sSoundFile, StaticSound.E_ENVMODE_LOCAL);
      if(sSound == null) {
         System.err.println("Sound file not found");
         return;
      }
      sSound.setPosition(new Vector3f(-27.72f, 19.767f, -288.752f));
      sSound.setGain(100.0f);
   }

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


Thanks for your help!

Post August 17th, 2015, 10:48 am
TTD03 User avatar
True Addicts
True Addicts

Posts: 7306
Points on hand: 738.00 Points
Bank: 111,265.11 Points
Bump!
Help guys! It's for the Six Flags Great Adventure recreation :D

Post August 17th, 2015, 11:37 am

Posts: 138
Points on hand: 2,126.00 Points
Bank: 1,000.00 Points
Location: Texas
This happened to me too the other day while working on a dive coaster named "disco dive". I haven't fixed it yet but mabye try putting to seperate scripts for each sound in diffrent folders?


Return to NoLimits Coaster 2 Scripting

 


  • Related topics
    Replies
    Views
    Last post