User:Bobbyb30 Swashbuckler/Example

From Second Life Wiki
< User:Bobbyb30 Swashbuckler
Revision as of 08:13, 17 March 2010 by Bobbyb30 Swashbuckler (talk | contribs) (created example page, hopefully this will help someone out)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

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>



All samples, code, documentation on this page are released into public domain.