Here's the script that controlls the 4 movement scripts:
CODE
// Non-Physical Flying Vehicle
// A.K.A: How to exploit tricks in LSL to get your way
//
// (your way being: up to 254 prims on a vehicle, in this case)
// Author: Jesrad Seraph
// Modify and redistribute freely, as long as your permit free modification and redistribution
integer hidden_face = 5;
float max_fwd = 2.0; // max speed in m per quarter of a second
integer max_rot = 4; // max turning speed in degrees per quarter of a second
float hover_height = 1; // prefered minimum height above ground
float fwd_accel = 0.015625; // forward/back acceleration
float up_accel = 0.015625; // vertical acceleration
float inertia = 0.75; // movement slowdown rate
float moment = 0.5; // turning slowdown rate
// internal stuff, don't modify
vector velocity;
vector veloff = <0.5, 0.5, 0.5>;
integer timeout;
integer number = 100;
stop()
{
llResetOtherScript("move");
llResetOtherScript("move1");
llResetOtherScript("move2");
llResetOtherScript("move3");
llSetColor(velocity + veloff, hidden_face);
timeout = 0;
//llSetTimerEvent(0.0);
velocity = <0.0, 0.0, -0.5>;
if (timeout == 0)
{
llMessageLinked(LINK_THIS, max_rot, "nonphy", (key)((string)max_fwd));
llSetTimerEvent(0.05);
}
timeout = 12;
}
default
{
state_entry()
{
stop();
}
on_rez(integer param)
{
llResetScript();
}
timer()
{
if (--timeout == 0)
{
llResetOtherScript("move");
llResetOtherScript("move1");
llResetOtherScript("move2");
llResetOtherScript("move3");
llSetTimerEvent(0.0);
return;
}
if (velocity.z > 0.0) velocity.z = 0.0;
velocity.z -= up_accel;
if (velocity.z < -0.5 ) velocity.z = -0.5;
if (llGetPos() * <0,0,1> < llGround(llGetPos()) + hover_height)
{
velocity.z = -0.25;
llMessageLinked(LINK_ALL_OTHERS, number, "", NULL_KEY);
number++;
}
if (llVecDist(llGetPos(), llGround(llGetPos()) * <0,0,1>) < 11.0)
{
velocity.z = -0.05;
}
if (llVecDist(llGetPos(), llGround(llGetPos()) * <0,0,1>) < 0.05)
{
velocity.z = 0;
}
llSetColor(velocity + veloff, hidden_face);
}
}
And here's the code for one of the movement scripts (they are all the same, just numbered differently)
CODE
integer hidden_face = 5;
float max_vel;
vector veloff = <-0.5, -0.5, -0.5>;
default
{
link_message(integer part, integer code, string msg, key id)
{
if (msg != "nonphy") return;
max_vel = (float)((string)id);
llSleep(0.05 * (integer)llGetSubString(llGetScriptName(), -1, -1));
while(TRUE)
{
llSetPos(max_vel * (llGetColor(hidden_face) + veloff) + llGetPos());
llSetPos(max_vel * (llGetColor(hidden_face) + veloff) + llGetPos());
llSetPos(max_vel * (llGetColor(hidden_face) + veloff) + llGetPos());
llSetPos(max_vel * (llGetColor(hidden_face) + veloff) + llGetPos());
llSetPos(max_vel * (llGetColor(hidden_face) + veloff) + llGetPos());
}
}
}
