Wiki
Clone wikiNuclearThroneTogether / Scripting / API / Input
Button inputs
Due to implementation details (both need for gamepad support and networking functions), mods do not have direct access to keyboard-polling functions. They do, however, have access to a set of wrapper functions that the game itself uses:
button_check(player, button) button_pressed(player, button) button_released(player, button)
player is a 0-based player index (0 for P1, 1 for P2), while button is to be one of the following string constants:
nort: North/Upsout: South/Downwest: West/Lefteast: East/Rightfire: Button used for shooting (default: left mouse button)spec: Button used for active ability (default: right mouse button)swap: Button used to swap weapons (default: space; mouse wheel)pick: Button used to pick up weapons (default: E)paus: Button used to pause the game (default: P; Esc)okay: Button used to confirm actions in menu (default: Enter)exit: Button used to close menus (default: Esc)horn: Button used for airhorn[.wav] (default: B)talk: Not an actual button - returns whether the player has chat open.key1: Button for picking mutation/emoticon 1 (default: 1)key2: Button for picking mutation/emoticon 2 (default: 2)key3: Button for picking mutation/emoticon 3 (default: 3)key4: Button for picking mutation/emoticon 4 (default: 4)key5: Button for picking mutation/emoticon 5 (default: 5)key6: Button for picking mutation/emoticon 6 (default: 6)key7: Button for picking mutation 7 (default: 7)key8: Button for picking mutation 8 (default: 8)key9: Button for picking mutation 9 (default: 9)
So, if you were to display a chat message whenever any player presses the airhorn button, you would do
#!js with (Player) if (button_pressed(index, "horn")) { trace("P" + string(index + 1) + " pressed airhorn!"); }
Aiming
Aiming is a little more familiar - you still have access to mouse_x and mouse_y variables, but there's a catch - these now accept a player index exactly like view_ variables do.
Therefore, mouse_x[1] will return in-room mouse coordinate for second player.
If you need to find coordinates relative to view, view_xview and view_yview are also exposed, and accept player indexes as well.
As an example, the following code will create an explosion wherever players place emoticon #1 (digit key 1):
#!js with (Player) if (button_pressed(index, "key1")) { instance_create(mouse_x[index], mouse_y[index], Explosion); }
Updated