Code: Select all
rotation temp;
integer delay = 12;
integer count = 0;
integer switch = TRUE;
float rnd = 2;
float z;
setLocalRot(rotation rot)
{
rotation localRot = llGetLocalRot();
rotation parentRot = llGetRot();
localRot.s = -localRot.s;
parentRot = localRot * parentRot; //Order of ops important here.
parentRot.s = -parentRot.s;
llSetRot(rot * parentRot);
}
default
{
state_entry()
{
llSetRot(llEuler2Rot(<0,0,180>*DEG_TO_RAD));
z = 180;
//setLocalRot(llEuler2Rot(<0,0,0>*DEG_TO_RAD));
llSetTimerEvent(0.0);
llStopSound();
llSetTimerEvent(0.2);
}
timer()
{
if(switch) {
rnd += -rnd;
switch = FALSE;
} else {
rnd = (llFrand(2) - 1);
switch = TRUE;
}
float x = rnd;
float y = rnd;
z += (llFrand(20) - 20);
if(z > 360) { z -= 360;}
else if(z < 0) { z += 360;}
setLocalRot(llEuler2Rot(<x,y,z>*DEG_TO_RAD));
// float t = llFrand(5.0) + 3;
// llSetTimerEvent(t);
}
on_rez(integer start_param)
{
llResetScript();
}
}