Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Imaginary Box Script

Pastrami Pestana
Sexual Inuendo
Join date: 12 Jul 2006
Posts: 31
02-13-2007 17:24
I found a script recently that I forgot to save. Whoops.

Basically, it defined an imaginary box. The prim that you put the script in will bounce around in that area, without leaving the dimensions given (i.e. 5x5x5). I don't know if anybody knows where I may find it, but if you know where, please tell me! Thanks!
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
02-14-2007 00:45
From: Pastrami Pestana
I found a script recently that I forgot to save. Whoops.

Basically, it defined an imaginary box. The prim that you put the script in will bounce around in that area, without leaving the dimensions given (i.e. 5x5x5). I don't know if anybody knows where I may find it, but if you know where, please tell me! Thanks!



Previously covered here
Dustin Widget
Script Monkey for hire
Join date: 15 Feb 2006
Posts: 101
02-14-2007 10:45
Here is a take on Newgate's code from the link, this should suit your purpose.

Should work.

CODE

vector startpos;
float imaginary_depth = 5;
float imaginary_width = 5;
float imaginary_height = 5;



Move()
{
vector moveto = startpos - <imaginary_depth,imaginary_width,imaginary_height> + <llFrand(imaginary_depth),llFrand(imaginary_width),llFrand(imaginary_height)>;
float time = llFrand(2) + 1;
llMoveToTarget(moveto,time);
llSetTimerEvent(time);

}


default
{
on_rez(integer num)
{
llResetScript();
}

state_entry()
{
llSetBuoyancy(0);
llSetStatus(STATUS_PHYSICS,FALSE);//Turns off physics
llSetStatus(STATUS_PHANTOM,FALSE);//Turns off phantom
startpos=llGetPos();
}

touch_start(integer total_number)
{
if(llDetectedKey(0) == llGetOwner())
{
state running;
}
}

}

state running
{
on_rez(integer num)
{
llResetScript();
}

state_entry()
{
llSetBuoyancy(1);//allows the object to hover
llSetStatus(STATUS_PHYSICS,TRUE);//Turns on physics
llSetStatus(STATUS_PHANTOM,TRUE);//Turns on phantom
Move();
}

touch_start(integer total_number)
{
if(llDetectedKey(0) == llGetOwner())
{
llSetPos(startpos);
llSetTimerEvent(0);
state default;
}
}

timer()
{
Move();
}
}