Unofficial LSL Reference

[[functions:lltakecontrols]]


Unofficial LSL reference

User Tools

Login

You are currently not logged in! Enter your authentication credentials below to log in. You need to have cookies enabled to log in.

Login

Forgotten your password? Get a new one: Set new password

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

functions:lltakecontrols [2018-03-30 09:41 SLT]
sei created
functions:lltakecontrols [2018-03-30 11:55 SLT] (current)
sei link to control event for details
Line 8: Line 8:
 Enables the user to use certain control keys or mouse button presses for interacting with a script. Enables the user to use certain control keys or mouse button presses for interacting with a script.
  
-Requires $lct[PERMISSION_CONTROL] permissions.+Requires $lct[PERMISSION_TAKE_CONTROLS] permissions.
  
 ===== Parameters ===== ===== Parameters =====
Line 24: Line 24:
  
   * Even if $prm[pass_on] is $ct[TRUE], when $lct[CONTROL_ML_LBUTTON] is in the controls, mouse clicks are blocked while in mouselook ($JIRA[SVC-4973],​ $JIRA[SVC-7532],​ declared as expected behaviour).   * Even if $prm[pass_on] is $ct[TRUE], when $lct[CONTROL_ML_LBUTTON] is in the controls, mouse clicks are blocked while in mouselook ($JIRA[SVC-4973],​ $JIRA[SVC-7532],​ declared as expected behaviour).
-  * While it's possible for two scripts in the same prim to take controls from two different users, that won't work as expected: there'​s no way to know the originator of the control. $TODO[Expand/​Test again]+  * While it's possible for two scripts in the same prim to take controls from two different users, that won't work as expected: there'​s no way to know the originator of the control. $TODO[Expand/​Test again] ​See the $lev[control] event for more details.
  
 ===== Short examples ===== ===== Short examples =====
  
 <code lsl2> <code lsl2>
-lltakecontrols(12); // will do xxx+// Capture the forward control, but let it still move the avatar forward. 
 +llTakeControls(CONTROL_FWDTRUE, TRUE); 
 + 
 +// Capture all controls that let the agent move (it can still move when pushed or falling) 
 +llTakeControls(CONTROL_FWD|CONTROL_BACK 
 +              |CONTROL_LEFT|CONTROL_RIGHT 
 +              |CONTROL_UP|CONTROL_DOWN 
 +              |CONTROL_ROT_LEFT|CONTROL_ROT_RIGHT 
 +              , TRUE, FALSE);
 </​code>​ </​code>​
  
 ===== Complete examples ===== ===== Complete examples =====
  
-<file lsl2 lltakecontrols-example.lsl>​+This example will report presses of the UP and DOWN controls in chat, after permissions are granted. 
 + 
 +<file lsl2 llTakeControls-example.lsl>​
 default default
 { {
     state_entry()     state_entry()
     {     {
-        ​lltakecontrols(12);+        ​llRequestPermissions(llGetOwner()PERMISSION_TAKE_CONTROLS);​ 
 +    } 
 + 
 +    run_time_permissions(integer perms) 
 +    { 
 +        if (perms & PERMISSION_TAKE_CONTROLS) 
 +            llTakeControls(CONTROL_UP | CONTROL_DOWN,​ TRUE, TRUE); 
 +    } 
 + 
 +    controls(key avatar, integer level, integer edge) 
 +    { 
 +        if (level & edge & CONTROL_UP) 
 +            llOwnerSay("​UP pressed"​);​ 
 +        if (~level & edge & CONTROL_UP) 
 +            llOwnerSay("​UP released"​);​ 
 +        if (level & edge & CONTROL_DOWN) 
 +            llOwnerSay("​DOWN pressed"​);​ 
 +        if (~level & edge & CONTROL_DOWN) 
 +            llOwnerSay("​DOWN released"​);
     }     }
 } }
Line 46: Line 74:
 ===== See also ===== ===== See also =====
  
-  * $lfn[llFunctiondoes such and such+  * $lfn[llReleaseControlsto release controls that were taken with $fn[llTakeControls], ​and also the $ct[PERMISSION_TAKE_CONTROLS] permission 
 +  * $lev[control] event, to be notified when controls are pressed and the $prm[accept] parameter is $ct[TRUE]. 
 +  * $lfn[llRequestPermissions],​ $lct[PERMISSION_TAKE_CONTROLS] and $lev[run_time_permissions] are typically needed in scripts that use this function.