User:Bobbyb30 Swashbuckler/Example
The following is an example of how to take and release controls of the owner on touch regardless of the prim this is in: <lsl> integer currentstate;//true have permissions, false do not have pemrissions
default { state_entry() { llPassTouches(TRUE);//any prim that is touched will trigger the touch here }
touch_start(integer ab)
{
if(llDetectedKey(0) == llGetOwner())//check if owner
{
currentstate = ~currentstate;//switch state
if(currentstate)
llRequestPermissions(llGetOwner(), PERMISSION_TAKE_CONTROLS);//request permissions
else
llReleaseControls();//release controls
}
}
run_time_permissions (integer permission)
{
if(permission & PERMISSION_TAKE_CONTROLS)//if we were given permission
{
llOwnerSay("I've got control");
//llTakeControls(.....);//take controls
//do stuff here
}
else//if we weren't given permission
{
llOwnerSay("I haven't gotten control");
//do stuff here
}
}
} </lsl>
The following is an example of how to take and release controls of the owner on touch of the prim that this script is in: <lsl> integer currentstate;//true have permissions, false do not have pemrissions
default {
touch_start(integer ab)
{
if(llDetectedKey(0) == llGetOwner())//check if owner
{
if(llDetectedLinkNumber(0) == llGetLinkNumber())//check if this prim
{
currentstate = ~currentstate;//switch state
if(currentstate)
llRequestPermissions(llGetOwner(), PERMISSION_TAKE_CONTROLS);//request permissions
else
llReleaseControls();//release controls
}
}
}
run_time_permissions (integer permission)
{
if(permission & PERMISSION_TAKE_CONTROLS)//if we were given permission
{
llOwnerSay("I've got control");
//llTakeControls(.....);//take controls
//do stuff here
}
else//if we weren't given permission
{
llOwnerSay("I haven't gotten control");
//do stuff here
}
}
} </lsl>
The following code will kill a prim after 5 seconds and will also change the color of the prim to random one. <lsl> //Modified by Bobbyb30 Swashbuckler March 19, 2009
//take note that llSetPrimitiveParams has a built in delay of .2 seconds //you can have several different params in one call float time = 5.0;//the time default {
on_rez(integer param)
{
llResetScript();
}
state_entry()
{
llSetTimerEvent(time);
//llSetPrimitiveParams([PRIM_PHYSICS, TRUE, PRIM_TEMP_ON_REZ, TRUE]);
//llSetPrimitiveParams([PRIM_COLOR, ALL_SIDES, <llFrand(1),llFrand(1),llFrand(1)>, 1.0]);
llSetPrimitiveParams(
[PRIM_PHYSICS, TRUE, PRIM_TEMP_ON_REZ, TRUE,
PRIM_COLOR, ALL_SIDES, <llFrand(1),llFrand(1),llFrand(1)>, 1.0
]);
}
timer()
{
llDie();
llSleep(.1);
llDie();//sometimes it doesn't die...so do it again
}
} </lsl>
License
All samples, code, documentation on this page are released into public domain.