Sukk Wing Trains
If u show Car.nlvm its more easy to spot the fault
The script? If so it's:
import com.nolimitscoaster.;
import nlvm.math3d.;
public class Car extends Script implements TrackTriggerListener
{
//CODE BY: TheCodeMaster
bool OTSR = false;
bool LAPBAR = true;
/////////////// CHANGE THESE VARIABLES //////////////
String coastername = "WING";
float wheelSpeedModifier = 1.0f;
float restraintMode = 0;
float restraintOpenAmount = 110*0.0174533f;
float restraintOpenTime = 4.0f;
float stationTime = 50;
float restraintDelay = 12.0f;
bool shake = false;
// / DONT CHANGE THESE ONES /
bool restraintMode2 = true;
SceneObject sco;
SceneObjectElement[] camera = new SceneObjectElement[0];
SceneObjectElement[] wheel = new SceneObjectElement[0];
SceneObjectElement[] wheel2 = new SceneObjectElement[4];
SceneObjectElement[] restraints = new SceneObjectElement[0];
ExternalRideView[] erv = new ExternalRideView[0];
Coaster coaster;
TrackPos trackPos;
float distance = 0;
float range = 1000.0f;
Train train;
float wheelrot;
float restrot;
bool restOpen = false;
int carToAttach = 0;
static int carTo = 0;
static int carTo2 = 0;
static int carTo3 = 0;
static int carTo4 = 0;
static int carTo5 = 0;
static int carTo6 = 0;
float timer = -restraintDelay;
Matrix4x4f carMatrix = new Matrix4x4f();
Vector3f posOut = new Vector3f(0,0,0);
Vector3f pitchHeadBankOut = new Vector3f(0,0,0);
Vector3f pitchHeadBankOut2 = new Vector3f(0,0,0);
TrackTrigger t;
float lx,ly,lz;
public bool onInit(){
if(restraintMode == 1){
restraintMode2 = false;
}
sco = sim.getSceneObjectForEntityId(getParentEntityId());
Tools.matrixToPitchHeadBankPos(sco.getMatrix(), null, posOut);
if(posOut.y != (int)posOut.y){
//carToAttach = (int)(posOut.y*3.28084f);
}else{
//carToAttach = (int)(posOut.y);
}
if(sco == null){
System.err.println("Critical Error!");
System.err.println("Error: Script not attached to Scene Object, please fix in SCO editor.");
return false;
}
int i = 0;
while(sco.getElementForName("View" + i) != null){
i++;
}
System.out.println("Found " + i + " Cameras.");
camera = new SceneObjectElement[i];
erv = new ExternalRideView[i];
i = 0;
while(sco.getElementForName("Wheel" + i) != null){
i++;
}
wheel = new SceneObjectElement[i];
System.out.println("Found " + i + " Wheels.");
i = 0;
while(sco.getElementForName("Harness" + i) != null){
i++;
}
restraints = new SceneObjectElement[i];
System.out.println("Found " + i + " Restraints.");
for(int j = 0; j < erv.length; j++){
camera[j] = sco.getElementForName("View" + (j));
erv[j] = sim.createExternalRideView();
erv[j].setLabel("Enter Seat " + (j+1));
Vector3f posOuttemp = new Vector3f(0,0,0);
Tools.matrixToPitchHeadBankPos(camera[j].getAbsoluteMatrix(), null, posOuttemp);
erv[j].setEnterWarpPoint(posOuttemp,2.0f);
erv[j].setEnterWarpPointEnabled(true);
camera[j].setVisible(false);
}
for(int j = 0; j < wheel.length; j++){
wheel[j] = sco.getElementForName("Wheel" + (j));
wheel2[0] = sco.getElementForName("Wheel4");
wheel2[1] = sco.getElementForName("Wheel5");
wheel2[2] = sco.getElementForName("Wheel10");
wheel2[3] = sco.getElementForName("Wheel11");
}
for(int j = 0; j < restraints.length; j++){
restraints[j] = sco.getElementForName("Harness" + (j));
}
trackPos = sim.findNearestCoasterTrack(sco.getTranslation(), range);
if (trackPos == null){
System.err.println(" No track found within range of " + range + " meters.");
return false;
}
coaster = sim.getCoaster(coastername);
train = coaster.findNearestTrain(sco.getTranslation(), range);
if (train == null){
System.err.println(" No train found within range of " + range + " meters.");
return false;
}
t = coaster.getTrackTrigger("Station");
t.addTrackTriggerListener(this);
if(train == coaster.getTrainAt(0)){
carTo++;
carToAttach = carTo;
}
if(coaster.getTrainCount() >= 2 && train == coaster.getTrainAt(1)){
carTo2++;
carToAttach = carTo2;
}
if(coaster.getTrainCount() >= 3 && train == coaster.getTrainAt(2)){
carTo3++;
carToAttach = carTo3;
}
if(coaster.getTrainCount() >= 4 && train == coaster.getTrainAt(3)){
carTo4++;
carToAttach = carTo4;
}
if(coaster.getTrainCount() >= 5 && train == coaster.getTrainAt(4)){
carTo5++;
carToAttach = carTo5;
}
return true;
}
public void onTrainEntering(TrackTrigger trigger, Train train)
{
if(trigger == t && train == this.train){
restOpen = true;
restrot = 0;
}
}
public void onTrainLeaving(TrackTrigger trigger, Train train)
{}
float offset = 0;
float offseta = 0;
float offsetb = 0;
float offsetc = 0;
bool trkposdone = false;
bool reverse = false;
bool reversea = false;
bool reverseb = false;
Vector3f old = new Vector3f(0,0,0);
Vector3f new2 = new Vector3f(0,0,0);
public void onNextFrame(float tick){
offsetc += sim.getCurSimulationTickSec();
if(offsetc > 0.01){
distance += train.getSpeed()*offsetc;
offsetc = 0;
}
if(reverse && offset < 1.00 - Math.random()){
reverse = false;
}
if(reverse){
offset -=sim.getCurSimulationTickSec();
}else{
offset +=sim.getCurSimulationTickSec();
}
if(!reverse && offset > 1.00 + Math.random()){
reverse = true;
}
if(reversea && offseta < 1.00 - Math.random()){
reversea = false;
}
if(reversea){
offseta -=sim.getCurSimulationTickSec();
}else{
offseta +=sim.getCurSimulationTickSec();
}
if(!reversea && offseta > 1.00 + Math.random()){
reversea = true;
}
if(reverseb && offsetb < 1.00 - Math.random()){
reverseb = false;
}
if(reverseb){
offsetb -=sim.getCurSimulationTickSec();
}else{
offsetb +=sim.getCurSimulationTickSec();
}
if(!reverseb && offsetb > 1.00 + Math.random()){
reverseb = true;
}
train.getCarMatrix(carToAttach, carMatrix);
Tools.matrixToPitchHeadBankPos(carMatrix, pitchHeadBankOut, posOut);
sco.setRotation(pitchHeadBankOut);
if(!trkposdone){
trackPos = sim.findNearestCoasterTrack(sco.getTranslation(), range);
trkposdone = true;
}
sco.setTranslation(posOut);
wheelrot -= sim.getCurSimulationTickSec() * train.getSpeed()* wheelSpeedModifier;
Vector3f posOuttemp = new Vector3f(0,0,0);
for(int i = 0; i < wheel.length; i++){
if(i == 0 ||i == 2 ||i == 4 ||i == 6 ||i == 8 ||i == 10 ||i == 12 ||i == 14 ||i == 16){
wheel[i].setRotation(wheelrot,0,0);
}else{
wheel[i].setRotation(-wheelrot,0,0);
}
wheel2[0].setRotation(0,-wheelrot*(1/0.3141f)*3,0);
wheel2[1].setRotation(0,wheelrot*(1/0.3141f)*3,0);
wheel2[2].setRotation(0,-wheelrot*(1/0.3141f)*3,0);
wheel2[3].setRotation(0,wheelrot*(1/0.3141f)*3,0);
}
for(int i = 0; i < camera.length; i++){
if(erv[i].isActive()){
Tools.matrixToPitchHeadBankPos(sco.getMatrix(), pitchHeadBankOut2, null);
Tools.matrixToPitchHeadBankPos(trackPos.getTrackPosOnCenterRailsWithOffset(distance - 2.1f).getCenterRailsMatrix(), pitchHeadBankOut, null);
Vector3f temp = new Vector3f();
sco.getRotation(temp);
new2 = new Vector3f(pitchHeadBankOut.x-pitchHeadBankOut2.x,pitchHeadBankOut.y-pitchHeadBankOut2.y,pitchHeadBankOut.z-pitchHeadBankOut2.z);
if(lx < new2.x){
lx+=0.1 *sim.getCurSimulationTickSec();
}
if(lx > new2.x){
lx-=0.1 *sim.getCurSimulationTickSec();
}
if(ly < new2.y){
ly+=0.1 *sim.getCurSimulationTickSec();
}
if(ly > new2.y){
ly-=0.1 *sim.getCurSimulationTickSec();
}
if(lz < new2.z){
lz+=0.1 *sim.getCurSimulationTickSec();
}
if(lz > new2.z){
lz-=0.1 *sim.getCurSimulationTickSec();
}
if(shake){
camera[i].setRotation((0) + (float)Tools.switchRampC2(1, 0.1, 0.5, (float)(offseta/10 * (train.getSpeed())/7)),(0) + (float)Tools.switchRampC2(1, 0.1, 0.5, (float)(offsetb/10 * (train.getSpeed())/7)),(0) + (float)Tools.switchRampC2(1, 0.1, 0.5, (float)(offset/10 * (train.getSpeed())/7)));
}
old = new Vector3f(pitchHeadBankOut.x-pitchHeadBankOut2.x,pitchHeadBankOut.y-pitchHeadBankOut2.y,pitchHeadBankOut.z-pitchHeadBankOut2.z);
}
Tools.matrixToPitchHeadBankPos(camera[i].getAbsoluteMatrix(), null, posOuttemp);
erv[i].setEnterWarpPoint(posOuttemp,2.0f);
erv[i].setCameraMatrix(camera[i].getAbsoluteMatrix());
}
if(restOpen){
timer += sim.getCurSimulationTickSec();
for(int i = 0; i < restraints.length; i++){
if(restraintMode2 == LAPBAR){
restraints[i].setRotation(restrot,0,0);
}else{
restraints[i].setRotation(-restrot,0,0);
}
}
if(timer > 0 && timer < (stationTime-restraintOpenTime)){
restrot = (float)Tools.switchRampC2(restraintOpenTime, restraintOpenAmount, restraintOpenTime/2, timer);
}else
if(timer < stationTime && timer > (stationTime-restraintOpenTime)){
restrot = -(float)Tools.switchRampC2(restraintOpenTime, restraintOpenAmount, restraintOpenTime/2, timer-(stationTime-restraintOpenTime))+restraintOpenAmount;
}else if (timer > stationTime){
restOpen = false;
timer = -restraintDelay;
}
}
}
}
Now we can't see the line Numbers
Make it downloadable on Google drive or send me your PKG file of your park.
Send it to my email (see my profile)
I got your email.Let me look into this.
Did u place a (UNFREEZE) train in your park with in the 1000.0f meters from the object u want to attach to the train ?
Did u name the coaster "WING" ?
Let me know
Yes, the coaster I want to attatch it to is unfrozen and within 1000 meters of the object
CoasterPost posted on December 13th, 2023
Yes, the coaster I want to attatch it to is unfrozen and within 1000 meters of the object
OK, u know how to make a PKG file of your park ?
Send me to same email adress.
Thank you for being so helpful by the way
I got your email. I will look into it.
EDIT :
U didn't place the a tracktrigger (required by the script)

I removed 1 train (there was only for 1 train custom coaches added)
U can put train 2 back if u add more coaches otherwise u get a error of 2 trains on 1 block)
Problem solved
wait, so how or where am I meant to put a track trigger?
Yes it was that simple
See in the image showing 1376 meter.
Just before the station.
CoasterPost posted on December 14th, 2023
wait, so how or where am I meant to put a track trigger?
U got it working?
CoasterPost posted on December 17th, 2023
Yeah!
Feel free to ask again.

Hey guys, just curious how to make these wing trains attach to the wireframe train. I'm pretty stupid, so I probably missed something obvious and I'm sorry if I did! 😅
This is what messages say:
Exception: NullPointerException
at public bool Car.onInit() in file C:\Users\User\Documents\com.nolimitscoaster.nolimits2\Intamin WingRider\Sukk Wing Trains\Wing Trains\Car.nlvm in line 137
at public final void com.nolimitscoaster.Script.run()