Input
Users interact with objects by clicking them, and with scripted vehicles, weapons and HUDs through captured controls. A script can capture movement keys and the mouse button, and read gamepad buttons and axes.
Input is not free text: for choices and typed input, use dialogs, text boxes or chat commands.
Touch needs no permission. Controls need PERMISSION_TAKE_CONTROLS; gamepads need PERMISSION_GAME_CONTROL and viewer support.
Concepts
- Clicking an object raises touch events, with who touched, which prim and
whereread by the detected functions- A click action changes what a left-click does
- Scripts can
capturemovement keys and the left mouse button- Needs
permissionfrom the avatar, granted inrun_time_permissions - The
controlevent reports which keys are held and which changed - Controls can also pass through to normal movement
- Sitting avatars can be forced into mouselook, and agent info tells whether an avatar is in mouselook
- Needs
- Gamepad buttons and axes arrive in
game_control, for scripts in attachments or seats
Functions and events
event | touch_start(integer num_detected) |
event | touch(integer num_detected) |
event | touch_end(integer num_detected) |
integer | llDetectedTouchFace(integer index) |
void | llSetClickAction(integer action) |
void | llTakeControls(integer controls, integer accept, integer pass_on) |
void | llReleaseControls() |
event | control(key id, integer level, integer edge) |
event | game_control(key id, integer button_levels, list axes) |
Touch
Touch events, where a prim was touched, click actions and touch text.
Gamepad
Game controller buttons and axes and the avatar’s game-control mode, with modal axes and buttons per mode.
Scripting Details
void | 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. |
event | run_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). |
void | 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. |
void | llReleaseControls()Stops taking inputs (previously acquired via llTakeControls) from the avatar, dequeuing any remaining control events and revoking the PERMISSION_TAKE_CONTROLS permission. |
event | control(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). |
void | 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. |
integer | llGetAgentInfo(key id)Returns an integer bitfield containing status information about the agent specified by id (such as AGENT_FLYING, AGENT_ATTACHMENTS, AGENT_SITTING, etc.). |
Additional
llRequestPermissions— permissions for inputPERMISSION_TAKE_CONTROLS— allowsllTakeControlsPERMISSION_GAME_CONTROL— needed for gamepad input
llTakeControls— keys to capture areCONTROL_*control buttons
Keyboard and mouse controls
Section titled “Keyboard and mouse controls”Constant groups ControlButton 10
See also Category InputSL Wiki LSL ControlsPlanned Guide: capturing controls for a vehicle or weapon