Skip to content

All Comments

12461 to 12480 of 19729

Filter comments

The Official Scripting Ask Thread
Scripting

If you want to use the sine curve, you can for example apply the sin function like this:

import com.nolimitscoaster.SceneObject;
import com.nolimitscoaster.SceneObjectElement;
import com.nolimitscoaster.Script;
import nlvm.lang.Math;

public class bear extends Script {
    private static final float AMPLITUDE = 0.3f;
    private static final float ROTATION_RATE = 0.1f;
    private static final float PI_2 = (float) (2 * Math.PI);
    private float offset = 0;

    private SceneObjectElement elem;

    public bool onInit() {
        SceneObject sco = sim.getSceneObjectForEntityId(getParentEntityId());
        elem = sco.getElementForName("Bear");
        return true;
    }

    public void onNextFrame(float tick) {
        offset += ROTATION_RATE * tick;

        //keeps the offset within the [0, 2*Pi) interval
        while (offset >= PI_2) {
            offset -= PI_2;
        }

        elem.setRotation(0, (float) Math.sin(offset) * AMPLITUDE, 0);
    }
}
View comment
Coasterdynamix Scorpion Train
Off Topic

Dang. My bad! Jetpulse, i think your talking about the link limiter. I need 2 cars, preferably in white and red. What color are your Franken cars? (im REALLY ocd) but I would prefer to replace the whole train. BUT, if i have to, ill live with it. I would like 2 cars in white and red (ONLY IF POSSIBLE) But I would prefer to replace the whole train. I would be fine with 2 cars though. I could run the two different colored ones in the front and rear. But i would prefer to replace the whole train.I am fine with just 2 cars though. (Preferably both the same color, but color doesent matter.) MUST HAVE THE METAL WHEELS, but I would prefer to replace my whole train.

View comment
The Official Scripting Ask Thread
Scripting

Bestdani, as u described in the last few lines of your post thats exactly what i'm looking for, but i don't know how to put that in script form.

I looked in the HELP from NL2, but couldn't find anything usefull to keep the script running error free.

View comment
The Official Scripting Ask Thread
Scripting

There are many ways to continue or do this, it depends on the final context what you want to achieve. What's not clear is if you want to repeat the whole cycle.

One way to do this is just to mirror the "movement" once your animation touched the "barrier value".
This means just do something like y += direction * rotationrate * tick with direction = 1 initially, if y > barrier direction = -1 and if < -barrier direction = 1 (barrier = 0.3 in your case) again (maybe also do proper mirroring, by adding / subracting the difference to the barrier value).

What in these cases could also be used and maybe looks better is just to use a sine curve for the movement, like amplitude * sin(x) where x = speed * time (means x += speed * tick in script code). When amplitude is 0.3 the sine curve would oscillate between + 0.3 and - 0.3 then for example.

View comment
Coasterdynamix Scorpion Train
Off Topic

Like disco, it's hard to part with it especially knowing I can't replace it. Both of my trains are getting quite old at this point as well (13 and 14 years old) and I know some of the pieces don't run as efficient as they did out of the box so I generally work with a "primary" train that I made 8 cars and then have 6 cars that end up being spare parts to try to find the most efficient pieces. It might be easier for myself or disco to swallow if we gave up a car or 2 and you'd just have to live with a bit of a franken-train. The only issue is if you need a front car. All the cars are identical except the piece on the front car which holds the ball joint from the second car. Because this is unique, there's only 1 per train so if somebody gave that up, the whole train is useless as a standalone train. Although with the modern world of at-home 3D printing, one might be able to make a copy of that part.

View comment
The Official Scripting Ask Thread
Scripting

I wanna rotate an object untill value y = 0.3 then it has to go down to 0 and the rotation direction has to go in the opposite direction)

this is my script so far :

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

public class bear extends Script
{
private static final float rotationrate = 0.1f;
private float y = 0;

SceneObject sco;
SceneObjectElement elem;

public bool onInit()
{
	sco = sim.getSceneObjectForEntityId(getParentEntityId());
	elem = sco.getElementForName("Bear");
	return true;
}
	
public void onNextFrame(float tick)
{
	
	y += rotationrate * tick; // opposite direction i use : y-= rotationrate * tick
	{
	
	if (y < 0.3f) 
	
	elem.setRotation(new Vector3f(0,y,0)); // oposite direction  i use : elem.setRotation(new Vector3f(0,-y,0))
			
	
	// System.out.println("value :Y "+ y);
	}
}

}

Many thanks to all.
Something went wrong with posting script.

View comment
The Official Scripting Ask Thread
Scripting

The probably most simple way to do that might be this:

import com.nolimitscoaster.*;
import nlvm.lang.*;

public class TriggerDemo extends Script implements TrackTriggerListener {
    private TrackTrigger trigger;
    private Coaster coaster;

    public bool onInit() {
        coaster = sim.getCoasterForEntityId(getParentEntityId());
        trigger = coaster.getTrackTrigger("t");
        trigger.addTrackTriggerListener(this);
        return false;
    }

    public void onTrainEntering(TrackTrigger trigger, Train train) {
        if (train == coaster.getTrainAt(0)) {
            System.out.println("train 1 entered");
        } else if (train == coaster.getTrainAt(1)) {
            System.out.println("train 2 entered");
        }
    }

    public void onTrainLeaving(TrackTrigger trigger, Train train) {
    }
}
View comment
12461 to 12480 of 19729