Files
LSL-Scripts/Simple Train/Simple Train script.lsl.txt
Fred Beckhusen 68a6f7f2cb New Stuff
2020-09-29 12:27:50 -05:00

41 lines
943 B
Plaintext

float delay = 0.1;
integer m_STEPS = 16;
motionTo(vector dest,rotation rot) {
integer i;
vector currentpos = llGetPos();
vector step = (dest - currentpos) / m_STEPS;
for (i = 1;i <= m_STEPS; i++)
{
if (i == (m_STEPS / 2))
{
llSetRot(rot);
}
llSetPos(currentpos + (step * i));
}
llSensor("Track",NULL_KEY,ACTIVE | PASSIVE,10,PI/2);
}
default {
state_entry() {
llSensor("Track",NULL_KEY,ACTIVE | PASSIVE,10,PI/2);
}
changed(integer what) {
if (what & CHANGED_REGION_START){
llResetScript();
}
}
sensor(integer n) {
motionTo(llDetectedPos(0) +(llRot2Fwd(llDetectedRot(0)) / 10),llDetectedRot(0));
}
no_sensor()
{
llSetTimerEvent(10);
}
timer() {
llSensor("Track",NULL_KEY,ACTIVE | PASSIVE,10,PI/2);
llSetTimerEvent(0);
}
}