Skip to content

All Comments

6201 to 6220 of 19729

Filter comments

The Official Scripting Ask Thread
Scripting

coaster fan123 posted on October 28th, 2020

MrRC posted on October 27th, 2020

coaster fan123 posted on October 27th, 2020

does anyone know if there's a script for a working and functioning turn table like sandy blasting bronco or fury at bobbejaanland has?

This doesn't excist

the turntable or the script? cause a turntable is a thing

Both don't

Look here : https://nolimitscentral.com/forum/topic/25?page=10#c13735

View comment
The NoLimits 2 Mega Resource Thread - Guides, Tools, Scripts
NoLimits Coaster

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

public class DoorScript_Slide extends Script implements TrackTriggerListener
{
private SceneObject sco;
private SceneObjectElement leftDoor;

private static final int STATE_IDLE = 0;
private static final int STATE_OPENING = 1;
private static final int STATE_OPENING_REVERSED = 2;
private static final int STATE_CLOSING = 3;

// rotate up to 90 degrees
private static final float MAX_ANGLE = (float)(Math.PI / 0.5f);
private static final float SPEED = 5.0f;

private static final String OpenTriggerNamea = "Deur_1_Open";
private static final String CloseTriggerNamea = "Deur_1_Dicht";

// rotate around Y-Axis
private static final Vector3f AXIS = new Vector3f(1,0,0);

private int state;
private float rot;

private TrackTrigger OpenTriga;
private TrackTrigger CloseTriga;

private StaticSound doorSound;

private static final String scriptName = "DoorScript_Slide";

private final static String doorSoundFile = "Air.ogg";

public bool onInit()
{
sco = sim.getSceneObjectForEntityId(getParentEntityId());
if (sco == null)
{
//System.err.println(scriptName + ": the script is not part of a scene object");
return false;
}

leftDoor = sco.getElementForName("deur");
if (leftDoor == null)
{
  System.err.println(scriptName + ": element not found: Left");
  return false;
}   


doorSound = StaticSound.loadFromFile(doorSoundFile, 0);
if (doorSound == null)
{
  System.err.println(scriptName + ": could not load sound '" + doorSoundFile + "'");
  return false;
}

Vector3f pos = new Vector3f();

sco.getTranslation(pos);


doorSound.setPosition(pos);

// Setting to 'Local' will enable environmental (reverb) effects if this sound's position should be e.g. in a tunnel
doorSound.setEnvironmentMode(StaticSound.E_ENVMODE_LOCAL);

// These parameters affect the distance attenuation
doorSound.setDistanceParameters(2.0f, 0.8f);

final float range = 20;

// create triggers...
TrackPos trackPos = sim.findNearestCoasterTrack(pos, range);
if (trackPos == null)
{
  System.err.println(scriptName + ": no coaster found within a range of "+ range + " meters");
  return false;
}
else
{
  Coaster coaster = sim.getCoaster("Bermuda_Explorer");
 
  System.out.println(scriptName + ": Coaster found: " + coaster);

  System.out.println("Coaster Style is: " + coaster.getCoasterStyleId());


  // tell the triggers that they should call our onTrainEntering/onTrainLeaving methods
  // We have to implement the TrackTriggerListener interface
  
  OpenTriga = coaster.getTrackTrigger(OpenTriggerNamea);
  OpenTriga.addTrackTriggerListener(this);
  
  CloseTriga = coaster.getTrackTrigger(CloseTriggerNamea);
  CloseTriga.addTrackTriggerListener(this);
  
  
}

state = STATE_IDLE;
rot = 0;

return true;

}

public void onNextFrame(float fTickTime)
{
switch (state)
{
case STATE_IDLE:
// do nothing
break;
case STATE_OPENING:
{
rot += fTickTime * SPEED;
if (rot >= MAX_ANGLE)
{
rot = MAX_ANGLE;
state = STATE_IDLE;
}
leftDoor.setTranslation(new Vector3f(-rot, 0, 0));

  }
  break;
case STATE_OPENING_REVERSED:
  {
    rot -= fTickTime * SPEED;
    if (rot <= -MAX_ANGLE)
    {
      rot = -MAX_ANGLE;
      state = STATE_IDLE;
    }
    
  leftDoor.setTranslation(new Vector3f(-rot, 0, 0));
    
  
  }
  break;     
case STATE_CLOSING:
  {
    if (rot > 0)
    {
      rot -= fTickTime * SPEED;
      if (rot <= 0)
      {
        rot = 0;
        state = STATE_IDLE;
      }
    }
    else if (rot < 0)
    {
      rot += fTickTime * SPEED;
      if (rot >= 0)
      {
        rot = 0;
        state = STATE_IDLE;
      }
    }
    
  leftDoor.setTranslation(new Vector3f(-rot, 0, 0));
    
  
  }
  break;
}

}

/**

  • This method is part of the TrackTriggerListener Interface implementation

  • It will be called if the interface is registered for a trigger using the

  • addTrackTriggerListener method.
    */
    public void onTrainEntering(TrackTrigger trigger, Train train)
    {
    if (trigger == OpenTriga)
    {
    if (train.getSpeed() > 0)
    {
    state = STATE_OPENING;
    //doorSound.play();

    //printTrainPositionAndRotation(train);
    }
    }
    else if (trigger == CloseTriga)
    {
    if (train.getSpeed() < 0)
    {
    state = STATE_OPENING_REVERSED;
    //doorSound.play();
    }
    }
    }

/**

  • This method is part of the TrackTriggerListener Interface implementation
  • It will be called if the interface is registered for a trigger using the
  • addTrackTriggerListener method.
    */
    public void onTrainLeaving(TrackTrigger trigger, Train train)
    {
    if (trigger == OpenTriga)
    {
    if (train.getSpeed() < 0)
    {
    state = STATE_CLOSING;
    //doorSound.play();
    }
    }
    else if (trigger == CloseTriga)
    {
    if (train.getSpeed() > 0)
    {
    state = STATE_CLOSING;
    //doorSound.play();
    }
    }
    }

// This method demonstrates how to get the position and rotation of the first bogey
private void printTrainPositionAndRotation(Train train)
{
if (train.getBogieCount() > 0)
{
Vector3f pos = new Vector3f();
Vector3f front = new Vector3f();

  train.getBogieOrientationAndPosition(0, front, null, null, pos);

  System.out.println(scriptName + ": First bogey is at " + pos);

  double azimuthRad = Math.atan2(front.x, -front.z);
  double elevationRad = Math.atan2(front.y, Math.sqrt(front.x* front.x + front.z* front.z));

  System.out.println(scriptName + ": Yaw is " + Math.toDegrees(azimuthRad) + " degrees");
  System.out.println(scriptName + ": Pitch is " + Math.toDegrees(elevationRad) + " degrees");
}

}
}
Feel free to ask if u have any problems, some words are in Dutch Language

View comment
6201 to 6220 of 19729