This script will not work with more than 1 prim, I was hoping someone could help me.
string default_spot;
string current_spot;
float set_x;
float set_y;
float set_z;
vector new_pos;
vector temp_default;
rotation new_rot;
integer touch_event = 1;
integer counter = 1;
string state_current = "rotation";
default
{
on_rez(integer start_param)
{
llResetScript();
}
state_entry()
{
}
touch_start(integer total_number)
{
if ((touch_event == 1) && (llDetectedKey(0) == llGetOwner()))
{
default_spot = (string)llGetPrimitiveParams([PRIM_POS_LOCAL]);
llSetTimerEvent(0.1);
touch_event = 0;
}
else if ((touch_event == 0) && (llDetectedKey(0) == llGetOwner()))
{
llSetTimerEvent(0.0);
llSetPrimitiveParams([PRIM_POSITION, (vector)default_spot]);
llSetPrimitiveParams([PRIM_ROTATION, llEuler2Rot(<0, 0, 0> * DEG_TO_RAD)]);
touch_event = 1;
counter = 1;
state_current = "rotation";
}
}
timer()
{
if (state_current == "rotation")
{
new_rot = llEuler2Rot(<0, 0, (360.0 + llFrand(-360.0))> * DEG_TO_RAD);
llSetPrimitiveParams([PRIM_ROTATION, new_rot]);
state_current = "prep";
}
else if (state_current == "prep")
{
current_spot = (string)llGetPrimitiveParams([PRIM_POSITION]);
set_z = 0.05 + llFrand(-0.1);
temp_default = (vector)default_spot;
state_current = "movement";
}
else if (state_current == "movement")
{
new_pos = llGetPos() + <0.05, 0.0, set_z> * llGetRot();
if ((temp_default.x - new_pos.x < 5.0) && (temp_default.x - new_pos.x > -5.0) && (temp_default.y - new_pos.y < 5.0) && (temp_default.y - new_pos.y > -5.0) && (temp_default.z - new_pos.z < 1.5) && (temp_default.z - new_pos.z > -1.5))
{
llSetLinkPrimitiveParamsFast(0, [PRIM_POSITION, new_pos]);
}
counter++;
if (counter == 20)
{
llSleep(5.0);
counter = 1;
state_current = "rotation";
}
}
}
}