Inputs
Keycodes
Click -> keycode
SecondaryClick -> keycode
DoubleClick -> keycode
TertiaryClick -> keycode
Tap -> keycode
DoubleTap -> keycode
ArrowUp -> keycode
ArrowLeft -> keycode
ArrowRight -> keycode
ArrowDown -> keycode
Digit0 -> keycode
Digit1 -> keycode
Digit2 -> keycode
Digit3 -> keycode
Digit4 -> keycode
Digit5 -> keycode
Digit6 -> keycode
Digit7 -> keycode
Digit8 -> keycode
Digit9 -> keycode
KeyA -> keycode
KeyB -> keycode
KeyC -> keycode
KeyD -> keycode
KeyE -> keycode
KeyF -> keycode
KeyG -> keycode
KeyH -> keycode
KeyI -> keycode
KeyJ -> keycode
KeyK -> keycode
KeyL -> keycode
KeyM -> keycode
KeyN -> keycode
KeyO -> keycode
KeyP -> keycode
KeyQ -> keycode
KeyR -> keycode
KeyS -> keycode
KeyT -> keycode
KeyU -> keycode
KeyV -> keycode
KeyW -> keycode
KeyX -> keycode
KeyY -> keycode
KeyZ -> keycode
F1 -> keycode
F2 -> keycode
F3 -> keycode
F4 -> keycode
F5 -> keycode
F6 -> keycode
F7 -> keycode
F8 -> keycode
F9 -> keycode
F10 -> keycode
F11 -> keycode
F12 -> keycode
KeySpacebar -> keycode
KeySemicolon -> keycode
KeyQuote -> keycode
KeyBackquote -> keycode
KeyBackslash -> keycode
KeyComma -> keycode
KeyPeriod -> keycode
KeySlash -> keycode
KeyMinus -> keycode
KeyEqual -> keycode
KeyBackspace -> keycode
KeyDelete -> keycode
KeyBracketLeft -> keycode
KeyBracketRight -> keycode
GamepadA -> keycode
GamepadB -> keycode
GamepadX -> keycode
GamepadY -> keycode
GamepadL1 -> keycode
GamepadL2 -> keycode
GamepadL3 -> keycode
GamepadR1 -> keycode
GamepadR2 -> keycode
GamepadR3 -> keycode
GamepadSelect -> keycode
GamepadStart -> keycode
GamepadHome -> keycode
KeyShiftLeft -> keycode
KeyShiftRight -> keycode
KeyTab -> keycode
KeyCapsLock -> keycode
KeyControlLeft -> keycode
KeyControlRight -> keycode
KeyAltLeft -> keycode
KeyAltRight -> keycode
KeyMetaLeft -> keycode
KeyMetaRight -> keycode
Keycode constants represent all the keyboard, mouse or touchscreen buttons that can be pressed.
ButtonDown
owner.ButtonDown([keycode])
Simulates a player pressing a button.
owner
(Entity): the player who pressed the button.keycode
(Keycode): the button that was pressed.
await owner.ButtonDown([keycode])
Waits for a player to press a button.
owner
(Entity): the player who pressed the button.keycode
(Keycode): the button that was pressed.
ButtonRemap
this.ButtonRemap<Id = auto>(fromKeycode, toKeycode, audience?=, [owner?])
delete this.ButtonRemap<Id>
Causes a keyboard/mouse button to be remapped to another button for a given audience.
Whenever fromKeycode
is pressed, toKeycode
will be triggered instead.
this
(Entity): The owner of this behavior. Whenthis
despawns, the remapping behavior will stop.fromKeycode
(Keycode or Array of Keycodes): They keycode that must be pressed to trigger the remapping. Multiple keycodes may be provided in an Array.toKeycode
(Keycode): The keycode that will be fired instead offromKeycode
.audience
(Entity, Symbol or Flag): If provided, the remapping will only apply to the specified audience. Defaults toowner
. See Audience.owner
(Entity): The player or team who owns the remapping. Only used to interpret theaudience
parameter.
ButtonUp
owner.ButtonUp([keycode])
Simulates a player releasing a button.
owner
(Entity): the player who released the button.keycode
(Keycode): the button that was released.
await owner.ButtonUp([keycode])
Waits for a player to release a button.
owner
(Entity): the player who released the button.keycode
(Keycode): the button that was released.
IsGamepadConnected
owner.IsGamepadConnected -> boolean
Returns whether the given owner
player has a Gamepad connected.
await owner.IsGamepadConnected -> boolean
Waits for Gamepad connected status to change for the given owner
player and returns the new status.
owner.IsGamepadConnected = boolean
Sets the Gamepad connected status for the given owner
player.
This can be used to simulate input for a bot player.
IsPointerActive
owner.IsPointerActive -> boolean
Returns whether the owner
player's pointer is currently active.
For a mouse, this means whether the mouse is within the borders of the game window or not.
For a touchscreen, this means whether the player is currently touching the screen or not.
The property can be set directly to simulate input, which can be used to program a bot player.
It is also possible to await
this property to wait until it changes.
If owner
is not a player entity, looks up its Owner and returns their pointer active state instead.
If owner
is nullish returns undefined
.
owner.IsPointerActive = boolean
Sets the owner
player's pointer active state.
This can be used to simulate input for a bot player.
If owner
is nullish or refers to a entity that is not a player, does nothing.
await owner.IsPointerActive -> boolean
Waits until the owner
player's pointer active state changes.
If owner
is nullish or refers to a entity that is not a player, waits forever.
Joystick
owner.Joystick -> vector
owner.Joystick2 -> vector
Returns the last known position of the owner
player's joystick, as a Vector.
The x
and y
components of the Joystick position will fall between -1
and 1
.
Joystick
typically refers to the left joystick on a gamepad,
while Joystick2
refers to the right joystick.
await owner.Joystick -> vector
await owner.Joystick2 -> vector
Waits for the owner
player's joystick to change and then returns the new position.
owner.Joystick = vector
owner.Joystick2 = vector
Sets the owner
player's joystick to the given position.
This can be used to simulate joystick input for a bot player.
KeyBindingDisplay
KeyBindingDisplay([keycode, ui=])
Adds an element to the user interface that displays
the key a player should press to trigger a particular keycode
,
considering any active key remappings.
keycode
(Keycode): the keycode of the keyboard key to display.ui
(UI): the slot in the user interface where the element will be inserted.
KeyRebindingBlock
KeyRebindingBlock([keycode], backgroundColor?=, color?, expand?, fontSize?, height?,
opacity?, reveal?, shadow?, stretch?, tooltip?, width?, [ui])
Adds an element to the user interface that allows the player to rebind one keyboard key to another one. The element will display the default key, and the user can click on it to change it. Rebindings are handled transparently by the engine and so no additional code is required to support rebindings besides adding this element to your game.
-
keycode
(Keycode): the keycode of the keyboard key to rebind. -
expand
(Boolean or Number): If set, expands the element to fill the remaining space of its container. The remaining space will be divided according to theexpand
value of all elements in the container. A value oftrue
is equivalent to1
. -
stretch
(Boolean): Iftrue
, will expand to fill the full cross-axis of its container. That is, if inside aVStack
, will expand to full width, whereas if inside anHStack
, will expand to full height. -
height
(Number): the height of the block. -
width
(Number): the width of the block. -
backgroundColor
(Color): the background color of the element. -
color
(Color): the text color of the element. -
fontSize
(Number): The size of the text, measured inem
units. -
opacity
(Number): the opacity of the element, from0
(transparent) to1
(opaque). -
reveal
(Boolean): Iftrue
, the element will be hidden until the mouse hovers over its panel. If the player is not using a mouse, the element will always be visible. -
shadow
(Number): the opacity of the drop shadow, from0
(no shadow) to1
(opaque shadow). -
tooltip
(String): the text to display when the mouse hovers over the element, or when it is waiting for the player to input a new key to rebind to. -
ui
(UI): the slot in the user interface where the element will be inserted.
KeyboardVirtualJoystick
this.KeyboardVirtualJoystick(up=, down, left, right, priority?, audience?, [owner?])
this.KeyboardVirtualJoystick2(up=, down, left, right, priority?, audience?, [owner?])
Makes the game simulate a virtual joystick for players that are using the keyboard.
-
this
(Entity): defines the lifespan of this behavior. Whenthis
despawns, the virtual mouse pointer behavior will stop. -
audience
(Entity, Symbol or Flag): If provided, the behavior will only apply to the specified audience. Defaults toowner
. See Audience. -
owner
(Entity): The player or team who owns this behavior. Only used to interpret theaudience
parameter. -
priority
(Number): if the same player has multipleKeyboardVirtualJoystick
behaviors, only the one with the highest priority will be active. Must be an integer between-128
and127
(inclusive). Defaults to0
. -
left
(Keycode or Array of Keycodes): Which keys to use for moving the joystick left. -
right
(Keycode or Array of Keycodes): Which keys to use for moving the joystick right. -
up
(Keycode or Array of Keycodes): Which keys to use for moving the joystick up. -
down
(Keycode or Array of Keycodes): Which keys to use for moving the joystick down.
See Keycodes for a full list of available Keycodes.
delete this.KeyboardVirtualJoystick
delete this.KeyboardVirtualJoystick2
Deletes any previously-added keyboard virtual joystick behavior from this entity.
Pointer
owner.Pointer -> vector
Returns the last known position of the owner
player's pointer.
For a mouse, this is the last known position of the mouse cursor.
For a touchscreen, this is the last touched position,
unless the TouchscreenVirtualPointer behavior applies to the player.
If owner
is not a player entity, looks up its Owner and returns their pointer position instead.
If owner
is nullish returns undefined
.
owner.Pointer = vector
Sets the position of the owner
player's pointer.
This can be used to simulate input for a bot player.
If owner
is nullish or refers to a entity that is not a player, does nothing.
await owner.Pointer -> vector
Waits until the owner
player's pointer position changes.
If owner
is nullish or refers to a entity that is not a player, waits forever.
ScreenSize
owner.ScreenSize -> vector
Returns the screen size of the given owner
player,
represented in em
units.
await owner.ScreenSize -> vector
Waits until the screen size of the given owner
player changes and returns the new screen size,
represented in em
units.
The screen size can change when the player resizes the window.
owner.ScreenSize = vector
Sets the screen size of the given owner
player.
The size should be specified in em
units.
This can be used to simulate input for a bot player.
ScrollWheelX
await owner.ScrollWheelX -> number
Waits until the owner
player uses their scroll wheel and returns the amount of horizontal scrolling,
in em
units.
If owner
is nullish or refers to a entity that is not a player, waits forever.
owner.ScrollWheelX(delta)
Simulates the owner
player using their scroll wheel to scroll horizontally by delta
em
units.
If owner
is nullish, does nothing.
ScrollWheelY
await owner.ScrollWheelY -> number
Waits until the owner
player uses their scroll wheel and returns the amount of vertical scrolling,
in em
units.
If owner
is nullish or refers to a entity that is not a player, waits forever.
owner.ScrollWheelY(delta)
Simulates the owner
player using their scroll wheel to scroll vertically by delta
em
units.
If owner
is nullish, does nothing.
TouchscreenMode
owner.TouchscreenMode -> bool
Returns true
if the player is using a touchscreen, false
otherwise.
This is determined by whether the player's first interaction was by touching the screen
(as opposed to clicking the mouse).
If the player has not interacted yet, this engine will return its best guess,
however its value may change once the player interacts.
This property will only ever change at most once per player.
The only way to enter the game fn
is by interacting with a button,
and so the touchscreen mode should always be confirmed when inside a game fn
.
Returns undefined
if the player
does not exist, is not a player, or is nullish.
await owner.TouchscreenMode -> bool
Waits until the player's touchscreen mode changes, then returns the new mode.
TouchscreenVirtualPointer
this.TouchscreenVirtualPointer(audience?=, priority?, [body?, owner?])
Makes the game simulate a virtual mouse pointer for any touchscreen players. Any touches to the screen will be translated to relative movements of a virtual mouse pointer.
this
(Entity): defines the lifespan of this behavior. Whenthis
despawns, the virtual mouse pointer behavior will stop.audience
(Entity, Symbol or Flag): If provided, this behavior will only apply to the specified audience. Defaults toowner
. See Audience.owner
(Entity): The player or team who owns this behavior. Only used to interpret theaudience
parameter.priority
(Number): if the same player has multipleTouchscreenVirtualPointer
behaviors, only the one with the highest priority will be active. Must be an integer between-128
and127
(inclusive). Defaults to0
.body
(Entity): if set, the virtual mouse pointer will move with thisbody
. This could be set to the hero unit that the player is controlling, for example. This may make it easier to control.
delete this.TouchscreenVirtualPointer
Deletes any previously-assigned TouchscreenVirtualPointer
behavior from this
entity.