Board index Roller Coaster Games NoLimits Coaster 2 NoLimits Coaster 2 Scripting Reading keyboard input (or another external trigger)

Reading keyboard input (or another external trigger)

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


Posts: 1
Points on hand: 56.00 Points
Hi all,
Is it possible to read keyboard input in NL2 scripts? So I can use certain keys to switch tracks, hide or show scenery, play audio etc.

Or, thinking ahead, to read a value from a file?

Would love to hear your suggestions :)

JK

Mikey User avatar
Site Admin
Site Admin

Posts: 1598
Points on hand: 6,054.50 Points
Location: Houston, Texas

Here is some examples. You will need to tie an action to the button.

import com.nolimitscoaster.*;

public class keyListener extends Script{
   public bool onInit(){
      return true;
   }
   public void onNextFrame(float t){
      if(Button.isPressed(Button.ACTION)){
         System.out.println("Mouse Button Pressed!");
      }
   }
}

import com.nolimitscoaster.*;

public class keyListener extends Script{
   private String mKey;
   public bool onInit(){
      mKey = Button.getAssignedKeyString(Button.ACTION);
      System.out.println("mKey = " + mKey);
      return true;
   }
   public void onNextFrame(float t){
   
   }
}
Image


Return to NoLimits Coaster 2 Scripting

 


  • Related topics
    Replies
    Views
    Last post
cron