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

Function: llTakeControls

llTakeControls(integer controls, integer accept, integer pass_on)

Enables the user to use certain control keys or mouse button presses for interacting with a script.

Requires PERMISSION_TAKE_CONTROLS permissions.

Parameters

controls

A bit mask of CONTROL_* constants

accept

Whether to generate control events for the specified controls. TRUE = generate them; FALSE = don't generate them.

pass_on

Whether the specified controls should still perform their normal functions (e.g. if CONTROL_FWD is among the controls to take, whether it still moves the avatar forward). TRUE = perform their normal functions too; FALSE = don't perform their normal functions. Note that a value of TRUE is not honoured for CONTROL_ML_LBUTTON

Notes

  • Even if pass_on is TRUE, when CONTROL_ML_LBUTTON is in the controls, mouse clicks are blocked while in mouselook (SVC-4973, 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. See the control event for more details.

Short examples

// Capture the forward control, but let it still move the avatar forward.
llTakeControls(CONTROL_FWD, TRUE, 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);

Complete examples

This example will report presses of the UP and DOWN controls in chat, after permissions are granted.

llTakeControls-example.lsl
default
{
    state_entry()
    {
        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");
    }
}

See also