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
Offline
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: 4,945.50 Points
Bank: 0.00 Points
Location: Houston, Texas
Offline
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

Sponsors
Did you know? Active community members enjoy an ad-free experience! Learn how ›
  • Rate 80%+ of your downloaded tracks (min 40 downloads)
  • Post at least 10 forum topics or replies in the last 90 days
  • Upload a track in the last 90 days
  • Earn 50,000+ points with a 10+ year account
  • Or become a Premium member

Return to NoLimits Coaster 2 Scripting

 


  • Related topics
    Replies
    Views
    Last post