Skip to content
lsl.devlsl.devLSL Dev

Control

Looking for the current API? Open the control reference →

Wiki description

Result of llTakeControls library function call and user input.

Specification

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

  • CONTROL_ROT_LEFT and CONTROL_ROT_RIGHT can be triggered when an object is selected or edited. If the user is running Viewer 2.0 and later, llGetAgentInfo will have AGENT_AUTOPILOT set in this case.
    • Sitting upon an object that takes control may also trigger CONTROL_FWD, CONTROL_BACK, CONTROL_DOWN and CONTROL_UP, depending on avatar position relative to the seat.
    • Autopilot control events can continue for a short time after AGENT_AUTOPILOT drops.
  • The 'levels' and 'edges' of the control() event both receive (CONTROL_FWD + CONTROL_BACK) (value 3) after teleport, effecting scripts that use this combination for faster movement. Calling llTakeControls() again after a llSleep(3) will filter this out.

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, FALSE);
                            // | 0 is for edit convenience,
                            // it does not change the mask.
        }
    }
    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

llGetRot in mouselook for an attachment returns the angle the avatar is looking in.
There are some bugs when you put two scripts in the same prim and call LlTakeControls(), the id may not be the intended one. See SVC-3187.

See also: functions

See also: events

Shared wiki helpers

The original page also injects shared parameter notes, caveats or issue information through these helpers. Their conditional MediaWiki logic is not reproduced here; inspect the preserved helper source for additional material.

Template:Issues/SCR-97

Original shared helper source (conditional wiki logic is not evaluated)
{{Issues|SCR-97|[[llTakeControls]] Traps repeating event when contols are changed or permission revoked|type=bug}}

Template:Issues/SVC-3187

Original shared helper source (conditional wiki logic is not evaluated)
{{Issues|SVC-3187|[[llTakeControls]] overrides existing controls|type=bug}}

Template:LSL Function/avatar

Original shared helper source (conditional wiki logic is not evaluated)
{{LSL Injection Test}}<noinclude>{{Multi-lang|category=LSL}}</noinclude>{{#if:

{{#vardefine:p_{{{1|none}}}_desc|avatar {{#if:{{{group|}}}|or group}} {{HoverLink|UUID|Universally Unique Identifier}} {{#if:{{{sim|}}}{{{region|}}}|that is in the same [[region]] {{#ifeq:{{{sim|}}}{{{region|}}}|known|or is otherwise known to the region{{Footnote|handle=known}}}}}}}}

{{#vardefine:p_{{{1|none}}}_hover|avatar {{#if:{{{group|}}}|or group}} UUID {{#if:{{{sim|}}}{{{region|}}}|that is in the same region {{#ifeq:{{{sim|}}}{{{region|}}}|known|or is otherwise known to the region}}}}}}

<includeonly>
{{#if:{{{nc|}}}||{{#vardefine:hidden-text|{{#var:hidden-text}}
{{#if:{{#pos:{{#var:moded}}|r}}{{#pos:{{#var:moded}}|u}}||{{LSLC|Avatar/As A Parameter||{{#var:lang}}}}}}
}}}}
</includeonly>

}}<noinclude>
{| {{Prettytable}}
|-{{Hl2}}
! #var
! value
|-
{{VarPair|p_{{{1|none}}}_desc}}
|-
{{VarPair|p_{{{1|none}}}_hover}}
|}
</noinclude>
Original wiki source

Some wiki templates and tables need their original context. View this article on the Second Life Wiki. Technical wording and examples are retained from the source; historical guidance may differ from current behavior.