LlTakeControls - Second Life Wiki

LlTakeControls

From Second Life Wiki

Jump to: navigation, search

Template:Needs Translation/LSL/de Template:Needs Translation/LSL/es Template:Needs Translation/LSL/el Template:Needs Translation/LSL/he Template:Needs Translation/LSL/it Template:Needs Translation/LSL/ko Template:Needs Translation/LSL/nl Template:Needs Translation/LSL/hu Template:Needs Translation/LSL/no Template:Needs Translation/LSL/da Template:Needs Translation/LSL/sv Template:Needs Translation/LSL/tr Template:Needs Translation/LSL/pl Template:Needs Translation/LSL/pt Template:Needs Translation/LSL/ru Template:Needs Translation/LSL/uk Template:Needs Translation/LSL/zh-Hans Template:Needs Translation/LSL/zh-Hant

Contents

Summary

Buggy
Function: llTakeControls( integer controls, integer accept, integer pass_on );
111 Function ID
0.0 Delay
10.0 Energy

Allows for intercepting of keyboard and mouse clicks, specifically those specified by controls, from the agent the script has permissions for.

• integer controls bitfield of CONTROL_* flags
• integer accept boolean, determines whether control events are generated
• integer pass_on boolean, determines whether controls are disabled

Requires the PERMISSION_TAKE_CONTROLS permission to run. If accept is FALSE and pass_on is FALSE, then the specified controls behave normally, and all other controls are disabled.
If accept is FALSE and pass_on is TRUE, then all controls behave normally.
If accept is TRUE and pass_on is FALSE, then the specified controls are disabled (but generate control events), and all other controls behave normally.
If accept is TRUE and pass_on is TRUE, then the specified controls generate control events, and all controls behave normally.

Constant Value Description
CONTROL_FWD 0x00000001 Move forward control ( or W)
CONTROL_BACK 0x00000002 Move back control ( or S)
CONTROL_LEFT 0x00000004 Move left control (⇧ Shift- or ⇧ Shift-A [ or A in mouselook])
CONTROL_RIGHT 0x00000008 Move right control (⇧ Shift- or ⇧ Shift-D [ or D in mouselook])
CONTROL_ROT_LEFT 0x00000100 Rotate left control ( or A)
CONTROL_ROT_RIGHT 0x00000200 Rotate right control ( or D)
CONTROL_UP 0x00000010 Move up control (PgUp or E)
CONTROL_DOWN 0x00000020 Move down control (PgDn or C)
CONTROL_LBUTTON 0x10000000 Left mouse button control
CONTROL_ML_LBUTTON 0x40000000 Left mouse button control while in mouselook

Caveats

  • Do not depend upon the auto-grant status of permissions. Always use the run_time_permissions event.
  • If the script lacks the permission PERMISSION_TAKE_CONTROLS, the script will shout an error on DEBUG_CHANNEL and the operation fails (but the script continues to run).
  • Once the PERMISSION_TAKE_CONTROLS permission is granted, it can be revoked from inside the script (with llReleaseControls or a new llRequestPermissions call), or if the user chooses Release Keys from the viewer. Otherwise, the script will only lose the permission if it is reset or the object derezzed (deleted, detached, or taken).

Important Issues

~ Search JIRA for related Bugs
Bug - A problem which impairs or prevents the functions of the product. Open - The issue is open and ready for the assignee to start work on it.    llTakeControls overrides existing controls

Examples

default
{
    state_entry()
    {
        llRequestPermissions(llGetOwner(), PERMISSION_TAKE_CONTROLS);
    }
    run_time_permissions(integer perm)
    {
        if(PERMISSION_TAKE_CONTROLS & perm)
        {
            llTakeControls(
                            CONTROL_FWD |
                            CONTROL_BACK |
                            CONTROL_LEFT |
                            CONTROL_RIGHT |
                            CONTROL_ROT_LEFT |
                            CONTROL_ROT_RIGHT |
                            CONTROL_UP |
                            CONTROL_DOWN |
                            CONTROL_LBUTTON |
                            CONTROL_ML_LBUTTON |
                            0, TRUE, TRUE);
        }
    }
    control(key id, integer level, integer edge)
    {
        integer start = level & edge;
        integer end = ~level & edge;
        integer held = level & ~edge;
        integer untouched = ~(level | edge);
        llOwnerSay(llList2CSV([level, edge, start, end, held, untouched]));
    }
}

Notes

If a script has taken controls, it and other scripts in the same prim will not be stopped if the Agent enters a No-Script Area. This is done to keep vehicle control alive and AOs functional. This is an intentional feature. These scripts will stop working if they call certain blacklisted functions.

See Also

Events

•  run_time_permissions Permission receiving event
•  control

Functions

•  llGetPermissions Get the permissions granted
•  llGetPermissionsKey Get the agent who granted permissions
•  llRequestPermissions Request permissions
•  llReleaseControls

Articles

•  Script permissions

Deep Notes

Issues

~ Search JIRA for related Issues
Bug - A problem which impairs or prevents the functions of the product. Open - The issue is open and ready for the assignee to start work on it.    llTakeControls overrides existing controls
This article wasn't helpful for you? Maybe the related article at the LSL Wiki is able to bring enlightenment.