llGetGameControlMode
integer llGetGameControlMode(key id// UUID of the avatar whose game-controller state to query.
);- Returns
integer- Energy
- 10
Returns the game-control mode the viewer of id was in when the current game_control input was generated.
Returns an integer that is one of the GAME_CONTROL_MODE_* constants, or -1 if no game-control data is available for id.
integer result = llGetGameControlMode(NULL_KEY);Specification
Section titled “Specification”The mode determines how the viewer maps the physical gamepad onto semantic (mode-dependent) axes and buttons, which are read with llGetGameControlModeAxes and llGetGameControlModeButtons.
| Constant | Value | Meaning |
|---|---|---|
GAME_CONTROL_MODE_AVATAR | 0 | Normal third-person avatar control. |
GAME_CONTROL_MODE_MOUSELOOK | 1 | Avatar is in mouselook. |
GAME_CONTROL_MODE_FLYCAM | 2 | Flycam (camera) control. |
GAME_CONTROL_MODE_CAPTIVE | 3 | Avatar is sitting, or controls have been taken. |
GAME_CONTROL_MODE_CURSOR | 4 | The left stick drives the on-screen mouse cursor. |
Caveats
Section titled “Caveats”- Only meaningful inside a
game_controlevent: the value is a snapshot taken when the event was queued, so that the mode, buttons and axes read by a script are all consistent with the event being processed. - Returns
-1when the script has no game-control snapshot for id, for example when called outside of agame_controlevent, or after the queued events for that agent have all been consumed. - Game-control input is only delivered to scripts which have been granted
PERMISSION_GAME_CONTROLby id. - The mode is chosen by the viewer, not by the script. It can change at any time (for example when the user enters mouselook or stands up), and a mode change on its own is enough to trigger a
game_controlevent. - New modes may be added in the future; do not assume the list above is exhaustive.
Examples
Section titled “Examples”Example 1
44 collapsed lines
default{ state_entry() { llOwnerSay("Ready for game_control events"); }
attach(key id) { if (id != NULL_KEY) { // game_control() event will only fire for object with permissions // request them when this object is attached llRequestPermissions(id, PERMISSION_GAME_CONTROL); } }
touch_start(integer num_detected) { // game_control() event will only fire for object with permissions // request them when this object is touched llRequestPermissions(llDetectedKey(0), PERMISSION_GAME_CONTROL); }
changed(integer change) { if (change & CHANGED_LINK) { key agent = llAvatarOnSitTarget(); if (agent != NULL_KEY) { // game_control() event will only fire for object with permissions // request them when this object is used as a seat llRequestPermissions(agent, PERMISSION_GAME_CONTROL); } } }
run_time_permissions(integer permissions) { // seats and attached objects will automatically accept PERMISSION_GAME_CONTROL // others will only get here when permissions are explicitly granted }
game_control(key id, integer button_levels, list axes) { integer mode = llGetGameControlMode(id); if (mode == GAME_CONTROL_MODE_FLYCAM) {16 collapsed lines
// 7 semantic axes: truck, dolly, pan, tilt, boom, roll, zoom llOwnerSay("flycam axes: " + llList2CSV(llGetGameControlModeAxes(id))); } else if (mode == GAME_CONTROL_MODE_CURSOR) { list a = llGetGameControlModeAxes(id); llOwnerSay("cursor pixels: <" + (string)llList2Float(a, 2) + ", " + (string)llList2Float(a, 3) + ">"); } else if (mode != -1) { // 5 semantic axes: strafe, advance, turn, look, rise llOwnerSay("movement axes: " + llList2CSV(llGetGameControlModeAxes(id))); } }}The mode and the semantic data are supplied by the viewer in the GameControlData message. Older viewers that only send the deprecated GameControlInput message still fire game_control events, but provide no mode, so this function returns -1 for them.
See also
Section titled “See also”Functions
Section titled “Functions”llGetGameControlModeAxes— Semantic axes for the current modellGetGameControlModeButtons— Semantic button bitfield for the current mode
Events
Section titled “Events”Articles
Section titled “Articles”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.