Skip to content

Commit 3f8b6ea

Browse files
Site changes [skip-ci]
1 parent e49f111 commit 3f8b6ea

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

_data/ref/alpha/go.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1749,7 +1749,7 @@
17491749
},
17501750
{
17511751
"brief": "called when user input is received",
1752-
"description": "This is a callback-function, which is called by the engine when user input is sent to the game object instance of the script.\nIt can be used to take action on the input, e.g. move the instance according to the input.\nFor an instance to obtain user input, it must first acquire input focus\nthrough the message <code>acquire_input_focus</code>.\nAny instance that has obtained input will be put on top of an\ninput stack. Input is sent to all listeners on the stack until the\nend of stack is reached, or a listener returns <code>true</code>\nto signal that it wants input to be consumed.\nSee the documentation of <a href=\"#acquire_input_focus\">acquire_input_focus</a> for more\ninformation.\nThe <code>action</code> parameter is a table containing data about the input mapped to the\n<code>action_id</code>.\nFor mapped actions it specifies the value of the input and if it was just pressed or released.\nActions are mapped to input in an input_binding-file.\nMouse movement is specifically handled and uses <code>nil</code> as its <code>action_id</code>.\nThe <code>action</code> only contains positional parameters in this case, such as x and y of the pointer.\nHere is a brief description of the available table fields:\n<table>\n<thead>\n<tr>\n<th>Field</th>\n<th>Description</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td><code>value</code></td>\n<td>The amount of input given by the user. This is usually 1 for buttons and 0-1 for analogue inputs. This is not present for mouse movement.</td>\n</tr>\n<tr>\n<td><code>pressed</code></td>\n<td>If the input was pressed this frame. This is not present for mouse movement.</td>\n</tr>\n<tr>\n<td><code>released</code></td>\n<td>If the input was released this frame. This is not present for mouse movement.</td>\n</tr>\n<tr>\n<td><code>repeated</code></td>\n<td>If the input was repeated this frame. This is similar to how a key on a keyboard is repeated when you hold it down. This is not present for mouse movement.</td>\n</tr>\n<tr>\n<td><code>x</code></td>\n<td>The x value of a pointer device, if present.</td>\n</tr>\n<tr>\n<td><code>y</code></td>\n<td>The y value of a pointer device, if present.</td>\n</tr>\n<tr>\n<td><code>screen_x</code></td>\n<td>The screen space x value of a pointer device, if present.</td>\n</tr>\n<tr>\n<td><code>screen_y</code></td>\n<td>The screen space y value of a pointer device, if present.</td>\n</tr>\n<tr>\n<td><code>dx</code></td>\n<td>The change in x value of a pointer device, if present.</td>\n</tr>\n<tr>\n<td><code>dy</code></td>\n<td>The change in y value of a pointer device, if present.</td>\n</tr>\n<tr>\n<td><code>screen_dx</code></td>\n<td>The change in screen space x value of a pointer device, if present.</td>\n</tr>\n<tr>\n<td><code>screen_dy</code></td>\n<td>The change in screen space y value of a pointer device, if present.</td>\n</tr>\n<tr>\n<td><code>gamepad</code></td>\n<td>The index of the gamepad device that provided the input.</td>\n</tr>\n<tr>\n<td><code>touch</code></td>\n<td>List of touch input, one element per finger, if present. See table below about touch input</td>\n</tr>\n</tbody>\n</table>\nTouch input table:\n<table>\n<thead>\n<tr>\n<th>Field</th>\n<th>Description</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td><code>id</code></td>\n<td>A number identifying the touch input during its duration.</td>\n</tr>\n<tr>\n<td><code>pressed</code></td>\n<td>True if the finger was pressed this frame.</td>\n</tr>\n<tr>\n<td><code>released</code></td>\n<td>True if the finger was released this frame.</td>\n</tr>\n<tr>\n<td><code>tap_count</code></td>\n<td>Number of taps, one for single, two for double-tap, etc</td>\n</tr>\n<tr>\n<td><code>x</code></td>\n<td>The x touch location.</td>\n</tr>\n<tr>\n<td><code>y</code></td>\n<td>The y touch location.</td>\n</tr>\n<tr>\n<td><code>dx</code></td>\n<td>The change in x value.</td>\n</tr>\n<tr>\n<td><code>dy</code></td>\n<td>The change in y value.</td>\n</tr>\n<tr>\n<td><code>acc_x</code></td>\n<td>Accelerometer x value (if present).</td>\n</tr>\n<tr>\n<td><code>acc_y</code></td>\n<td>Accelerometer y value (if present).</td>\n</tr>\n<tr>\n<td><code>acc_z</code></td>\n<td>Accelerometer z value (if present).</td>\n</tr>\n</tbody>\n</table>",
1752+
"description": "This is a callback-function, which is called by the engine when user input is sent to the game object instance of the script.\nIt can be used to take action on the input, e.g. move the instance according to the input.\nFor an instance to obtain user input, it must first acquire input focus\nthrough the message <code>acquire_input_focus</code>.\nAny instance that has obtained input will be put on top of an\ninput stack. Input is sent to all listeners on the stack until the\nend of stack is reached, or a listener returns <code>true</code>\nto signal that it wants input to be consumed.\nSee the documentation of <a href=\"#acquire_input_focus\">acquire_input_focus</a> for more\ninformation.\nThe <code>action</code> parameter is a table containing data about the input mapped to the\n<code>action_id</code>.\nFor mapped actions it specifies the value of the input and if it was just pressed or released.\nActions are mapped to input in an input_binding-file.\nMouse movement is specifically handled and uses <code>nil</code> as its <code>action_id</code>.\nThe <code>action</code> only contains positional parameters in this case, such as x and y of the pointer.\nHere is a brief description of the available table fields:\n<table>\n<thead>\n<tr>\n<th>Field</th>\n<th>Description</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td><code>value</code></td>\n<td>The amount of input given by the user. This is usually 1 for buttons and 0-1 for analogue inputs. This is not present for mouse movement and text input.</td>\n</tr>\n<tr>\n<td><code>pressed</code></td>\n<td>If the input was pressed this frame. This is not present for mouse movement and text input.</td>\n</tr>\n<tr>\n<td><code>released</code></td>\n<td>If the input was released this frame. This is not present for mouse movement and text input.</td>\n</tr>\n<tr>\n<td><code>repeated</code></td>\n<td>If the input was repeated this frame. This is similar to how a key on a keyboard is repeated when you hold it down. This is not present for mouse movement and text input.</td>\n</tr>\n<tr>\n<td><code>x</code></td>\n<td>The x value of a pointer device, if present. This is not present for gamepad, key and text input.</td>\n</tr>\n<tr>\n<td><code>y</code></td>\n<td>The y value of a pointer device, if present. This is not present for gamepad, key and text input.</td>\n</tr>\n<tr>\n<td><code>screen_x</code></td>\n<td>The screen space x value of a pointer device, if present. This is not present for gamepad, key and text input.</td>\n</tr>\n<tr>\n<td><code>screen_y</code></td>\n<td>The screen space y value of a pointer device, if present. This is not present for gamepad, key and text input.</td>\n</tr>\n<tr>\n<td><code>dx</code></td>\n<td>The change in x value of a pointer device, if present. This is not present for gamepad, key and text input.</td>\n</tr>\n<tr>\n<td><code>dy</code></td>\n<td>The change in y value of a pointer device, if present. This is not present for gamepad, key and text input.</td>\n</tr>\n<tr>\n<td><code>screen_dx</code></td>\n<td>The change in screen space x value of a pointer device, if present. This is not present for gamepad, key and text input.</td>\n</tr>\n<tr>\n<td><code>screen_dy</code></td>\n<td>The change in screen space y value of a pointer device, if present. This is not present for gamepad, key and text input.</td>\n</tr>\n<tr>\n<td><code>gamepad</code></td>\n<td>The index of the gamepad device that provided the input. See table below about gamepad input.</td>\n</tr>\n<tr>\n<td><code>touch</code></td>\n<td>List of touch input, one element per finger, if present. See table below about touch input</td>\n</tr>\n<tr>\n<td><code>text</code></td>\n<td>Text input from a (virtual) keyboard or similar.</td>\n</tr>\n<tr>\n<td><code>marked_text</code></td>\n<td>Sequence of entered symbols while entering a symbol combination, for example Japanese Kana.</td>\n</tr>\n</tbody>\n</table>\nGamepad specific fields:\n<table>\n<thead>\n<tr>\n<th>Field</th>\n<th>Description</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td><code>gamepad</code></td>\n<td>The index of the gamepad device that provided the input.</td>\n</tr>\n<tr>\n<td><code>userid</code></td>\n<td>Id of the user associated with the controller. Usually only relevant on consoles.</td>\n</tr>\n<tr>\n<td><code>gamepad_unknown</code></td>\n<td>True if the inout originated from an unknown/unmapped gamepad.</td>\n</tr>\n<tr>\n<td><code>gamepad_name</code></td>\n<td>Name of the gamepad</td>\n</tr>\n<tr>\n<td><code>gamepad_axis</code></td>\n<td>List of gamepad axis values. For raw gamepad input only.</td>\n</tr>\n<tr>\n<td><code>gamepadhats</code></td>\n<td>List of gamepad hat values. For raw gamepad input only.</td>\n</tr>\n<tr>\n<td><code>gamepad_buttons</code></td>\n<td>List of gamepad button values. For raw gamepad input only.</td>\n</tr>\n</tbody>\n</table>\nTouch input table:\n<table>\n<thead>\n<tr>\n<th>Field</th>\n<th>Description</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td><code>id</code></td>\n<td>A number identifying the touch input during its duration.</td>\n</tr>\n<tr>\n<td><code>pressed</code></td>\n<td>True if the finger was pressed this frame.</td>\n</tr>\n<tr>\n<td><code>released</code></td>\n<td>True if the finger was released this frame.</td>\n</tr>\n<tr>\n<td><code>tap_count</code></td>\n<td>Number of taps, one for single, two for double-tap, etc</td>\n</tr>\n<tr>\n<td><code>x</code></td>\n<td>The x touch location.</td>\n</tr>\n<tr>\n<td><code>y</code></td>\n<td>The y touch location.</td>\n</tr>\n<tr>\n<td><code>dx</code></td>\n<td>The change in x value.</td>\n</tr>\n<tr>\n<td><code>dy</code></td>\n<td>The change in y value.</td>\n</tr>\n<tr>\n<td><code>acc_x</code></td>\n<td>Accelerometer x value (if present).</td>\n</tr>\n<tr>\n<td><code>acc_y</code></td>\n<td>Accelerometer y value (if present).</td>\n</tr>\n<tr>\n<td><code>acc_z</code></td>\n<td>Accelerometer z value (if present).</td>\n</tr>\n</tbody>\n</table>",
17531753
"error": "",
17541754
"examples": "This example demonstrates how a game object instance can be moved as a response to user input.\n<div class=\"codehilite\"><pre><span></span><code><span class=\"kr\">function</span> <span class=\"nf\">init</span><span class=\"p\">(</span><span class=\"n\">self</span><span class=\"p\">)</span>\n <span class=\"c1\">-- acquire input focus</span>\n <span class=\"n\">msg</span><span class=\"p\">.</span><span class=\"n\">post</span><span class=\"p\">(</span><span class=\"s2\">&quot;.&quot;</span><span class=\"p\">,</span> <span class=\"s2\">&quot;acquire_input_focus&quot;</span><span class=\"p\">)</span>\n <span class=\"c1\">-- maximum speed the instance can be moved</span>\n <span class=\"n\">self</span><span class=\"p\">.</span><span class=\"n\">max_speed</span> <span class=\"o\">=</span> <span class=\"mi\">2</span>\n <span class=\"c1\">-- velocity of the instance, initially zero</span>\n <span class=\"n\">self</span><span class=\"p\">.</span><span class=\"n\">velocity</span> <span class=\"o\">=</span> <span class=\"n\">vmath</span><span class=\"p\">.</span><span class=\"n\">vector3</span><span class=\"p\">()</span>\n<span class=\"kr\">end</span>\n\n<span class=\"kr\">function</span> <span class=\"nf\">update</span><span class=\"p\">(</span><span class=\"n\">self</span><span class=\"p\">,</span> <span class=\"n\">dt</span><span class=\"p\">)</span>\n <span class=\"c1\">-- move the instance</span>\n <span class=\"n\">go</span><span class=\"p\">.</span><span class=\"n\">set_position</span><span class=\"p\">(</span><span class=\"n\">go</span><span class=\"p\">.</span><span class=\"n\">get_position</span><span class=\"p\">()</span> <span class=\"o\">+</span> <span class=\"n\">dt</span> <span class=\"o\">*</span> <span class=\"n\">self</span><span class=\"p\">.</span><span class=\"n\">velocity</span><span class=\"p\">)</span>\n<span class=\"kr\">end</span>\n\n<span class=\"kr\">function</span> <span class=\"nf\">on_input</span><span class=\"p\">(</span><span class=\"n\">self</span><span class=\"p\">,</span> <span class=\"n\">action_id</span><span class=\"p\">,</span> <span class=\"n\">action</span><span class=\"p\">)</span>\n <span class=\"c1\">-- check for movement input</span>\n <span class=\"kr\">if</span> <span class=\"n\">action_id</span> <span class=\"o\">==</span> <span class=\"n\">hash</span><span class=\"p\">(</span><span class=\"s2\">&quot;right&quot;</span><span class=\"p\">)</span> <span class=\"kr\">then</span>\n <span class=\"kr\">if</span> <span class=\"n\">action</span><span class=\"p\">.</span><span class=\"n\">released</span> <span class=\"kr\">then</span> <span class=\"c1\">-- reset velocity if input was released</span>\n <span class=\"n\">self</span><span class=\"p\">.</span><span class=\"n\">velocity</span> <span class=\"o\">=</span> <span class=\"n\">vmath</span><span class=\"p\">.</span><span class=\"n\">vector3</span><span class=\"p\">()</span>\n <span class=\"kr\">else</span> <span class=\"c1\">-- update velocity</span>\n <span class=\"n\">self</span><span class=\"p\">.</span><span class=\"n\">velocity</span> <span class=\"o\">=</span> <span class=\"n\">vmath</span><span class=\"p\">.</span><span class=\"n\">vector3</span><span class=\"p\">(</span><span class=\"n\">action</span><span class=\"p\">.</span><span class=\"n\">value</span> <span class=\"o\">*</span> <span class=\"n\">self</span><span class=\"p\">.</span><span class=\"n\">max_speed</span><span class=\"p\">,</span> <span class=\"mi\">0</span><span class=\"p\">,</span> <span class=\"mi\">0</span><span class=\"p\">)</span>\n <span class=\"kr\">end</span>\n <span class=\"kr\">end</span>\n<span class=\"kr\">end</span>\n</code></pre></div>",
17551755
"language": "",

0 commit comments

Comments
 (0)