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

Syntax

void llTakeControls( integer controls, integer accept, integer pass_on );

Forced delay: 0.0 seconds. Energy: 10.0.

Parameters

integer controls
bitfield of CONTROL_* flags
integer accept (boolean)
boolean, determines whether control events are generated
integer pass_on (boolean)
boolean, determines whether controls perform their normal functions

To run this function the script must request the PERMISSION_TAKE_CONTROLS permission with llRequestPermissions.

If accept is FALSE and pass_on is FALSE, the behavior is not intuitive. In this case, the complement of the specified controls do not generate events and do not perform their normal functions. They are effectively disabled. Certain control bits (e.g. CONTROL_ROT_LEFT) are also disabled when specified, in this case.
If accept is FALSE and pass_on is TRUE, then the specified controls do not generate events but perform their normal functions.
If accept is TRUE and pass_on is FALSE, then the specified controls generate events but do not perform their normal functions.
If accept is TRUE and pass_on is TRUE, then the specified controls generate events and perform their normal functions.

Constants

ConstantValueDescription
CONTROL_FWD0x00000001Move forward control (↑ or W)
CONTROL_BACK0x00000002Move back control (↓ or S)
CONTROL_LEFT0x00000004Move left control (← or A [← or A in mouselook])
CONTROL_RIGHT0x00000008Move right control (→ or D [→ or D in mouselook])
CONTROL_ROT_LEFT0x00000100Rotate left control (← or A)
CONTROL_ROT_RIGHT0x00000200Rotate right control (→ or D)
CONTROL_UP0x00000010Move up control (PgUp or E)
CONTROL_DOWN0x00000020Move down control (PgDn or C)
CONTROL_LBUTTON0x10000000Left mouse button control
CONTROL_ML_LBUTTON0x40000000Left mouse button control while in mouselook
(undocumented)0x02000000Avatar left rotation detected. Triggers llGetAnimation == "Turning Left"
(undocumented)0x04000000Avatar right rotation detected. Triggers llGetAnimation == "Turning Right"

Caveats

Permissions

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 ,
                            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 Outside Scripts" parcel. This is done to keep vehicle control alive and AOs functional. This is an intentional feature. This only applies to the object containing the script - child objects in a linkset (wheels, particle emitters, in vehicles, child objects in huds, etc) will not inherit this immunity. To preserve functionality in child objects, llTakeControls must be issued in each scripted child as well.

See also

Events

Functions

Articles

Deep notes

Issues