Skip to content

Controls

A script can capture an avatar’s movement keys and left mouse button, which is how vehicles, weapons and HUDs read input. Part of the Input feature.

Concepts

Functions and events

llRequestPermissions(key agent, integer permissions)
eventrun_time_permissions(integer perm)
llTakeControls(integer controls, integer accept, integer pass_on)
llReleaseControls()
eventcontrol(key id, integer level, integer edge)
llForceMouselook(integer mouselook)

Presses, releases and held keys

Combine level and edge in the control event:

integer start = level & edge; // pressed this event
integer end = ~level & edge; // released this event
integer held = level & ~edge; // still held

Touch

Clicking objects, touch positions, click actions and touch text.

Game Control

Controller-shaped buttons and axes, from a game controller or translated keyboard and mouse, and game-control modes.

Scripting Details

llRequestPermissions(key agent, integer permissions)
Requests permissions (a bitfield specified by permissions) from the agent in the same region, calling run_time_permissions if granted. This call does not pause script execution.
eventrun_time_permissions(integer perm)
Triggered when an agent grants or denies runtime permissions requested by llRequestPermissions. Passes the active integer permissions bitfield perm (returns 0 if no permissions are currently granted).
llTakeControls(integer controls, integer accept, integer pass_on)
Intercepts inputs (keyboard/mouse clicks) from the agent, specifically those specified by controls. The boolean accept determines if events are generated, and pass_on determines if inputs also perform their default functions. Requires the PERMISSION_TAKE_CONTROLS runtime permission.
llReleaseControls()
Stops taking inputs (previously acquired via llTakeControls) from the avatar, dequeuing any remaining control events and revoking the PERMISSION_TAKE_CONTROLS permission.
eventcontrol(key id, integer level, integer edge)
Triggered to pass captured avatar control inputs into the script. The parameter level indicates held controls, and edge indicates change in controls (both are bitfields of CONTROL_* constants).
llForceMouselook(integer mouselook)
Sets whether any avatar sitting on this prim is forced into mouselook mode. Setting mouselook to TRUE forces the mode; FALSE (default) allows the avatar to keep their current camera mode.
integerllGetAgentInfo(key id)
Returns an integer bitfield containing status information about the agent specified by id (such as AGENT_FLYING, AGENT_ATTACHMENTS, AGENT_SITTING, etc.).

Constant groups ControlButton 10

See also Feature InputFeature PermissionsCategory InputSL Wiki LSL ControlsPlanned Guide: capturing controls for a vehicle or weapon