LlGetGameControlMode
Looking for the current API? Open the llGetGameControlMode reference →
Wiki description
Returns the game-control mode the viewer of
id was in when the current game_control input was generated.Return value notes
Returns an integer that is one of the GAME_CONTROL_MODE_* constants, or -1 if no game-control data is available for
id.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
- Only meaningful inside a game_control event: 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 -1 when the script has no game-control snapshot for
id, for example when called outside of a game_control event, 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_CONTROL by
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_control event.
- New modes may be added in the future; do not assume the list above is exhaustive.
Examples
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)
{
// 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)));
}
}
}Notes
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: functions
See also: events
See also: 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.