Macros are used to convert keyboard and gamepad events into actions. There are two ways this works: A macro can run a command, or in some cases (such as gamepad controls) it can be used to remap one control to another.

A collection of macros is called a macro set, and the window currently in use defines which macro set will be used via its macro parameter.

Macros can be changed at runtime. If a macro does not have an id, you can refer to it by its key combination (name). If you have a macro set named macro1 and have a Ctrl+E macro for instance, you could use winset() with "macro1.Ctrl+E". See the Macro control for information on which parameters you can change with winset().

The name of the macro is actually the full key combination as it would appear in the macro editor, like CTRL+E, Space+REP, or Alt+Shift+F1. This is not case-specific and it doesn’t matter where you put modifiers like CTRL+, SHIFT+, etc.

The Any macro

Oftentimes it’s desirable to keep track of key presses yourself rather than have a hundred different macros defined. BYOND makes this possible via the Any and Any+UP macros, which respond to any key or gamepad button. UP is the only allowed modifier for this macro, since other modifier keys are handled by this same macro.

Typically, you will want to use set instant=1 on the verbs that will be tied to the Any macro, so that keyboard input doesn’t queue up and lag behind.

In the command that goes with this macro, [[*]] will be replaced with the name of the key or gamepad button that was pressed/released. (See embedded winget for more details on the [[...]] format.)

Mapping

The map-to parameter is used by mappings, which are like macros but are used to convert gamepad inputs easily and quickly to keyboard inputs. E.g., GamepadLeft can map to West which is the left arrow key. A set of default mappings will be added automatically at runtime if you don’t include any gamepad mapping in your project.

Gamepads

BYOND will support up to four gamepads, and breaks up their input into the following categories:

  • Buttons: Buttons on the controller that are either pressed or not pressed.
  • Directions: Directions pressed on the D-pad, which act like buttons. Diagonals are also included.
  • D-pad: The D-pad itself, which can be used to read a dir number.
  • Analog: The analog sticks (BYOND supports left and right).

See the list of available macros below for information on how to harness these inputs.

To let a user configure their gamepad, you need to call the client-side .gamepad-mapping command. Or, if they have access to the Options & Messages window and Dream Seeker’s default menus, they can reach it from there. However it’s a good idea to make this easy for them to find. Several common gamepads are already known by BYOND.

There is also the GamepadRaw macro, which is similar to Any in some ways and will avoid doing any processing (e.g. checking for dead zones on the analog sticks) so you can handle all input yourself. GamepadRaw does not rely on BYOND’s controller configuration, so it will not, for instance, know that button 0 should be GamepadFace1. See below for more information on how to use this macro.

Mouse macros

You can add macros (not local player-defined ones) for any of the mouse input commands, thereby bypassing the normal mouse verbs. This can be helpful for designing custom setups where you don’t want to have to parse the normal parameter string that provides most of the info, and instead want to provide data directly to the verb. You will want set instant=1 on any such verb.

Mouse macro commands use the [[...]] syntax to embed values, just like embedded wingets. These are the values you can include in a mouse macro:

Embedded keywordMeaning
actionName of the mouse action (e.g. MouseDown, MouseMove, etc.).
srcObject the mouse is touching, or dragging/dropping.
locTurf or statpanel that src is over; in a drag-drop you should split this into src.loc and over.loc.
buttonMouse button used for this action, if any: left, middle, or right.
dragMouse button currently used for dragging.
buttonsMouse buttons currently down or involved in this action, separated by commas.
keysModifier keys currently held (shift, ctrl, alt), separated by commas.
overObject the mouse is over in a drag/drop operation.
idControl ID; in a drag-drop you should split this into src.id and over.id.
iconThe icon offset (starting from 1,1 at the lower left) where the mouse action occurred.*
tileThe tile where the mouse action occurred, if relevant.*
visPixel coordinates relative to the icon’s position on screen (same as icon but without taking transform into account).*
screen_locThe regular screen_loc cordinate string.*
screenscreen_loc coordinates but entirely in pixels starting at 0,0 from lower left.*
screen_tilescreen_loc coordinates but only the tile number starting at 1,1.*
screen_offsetscreen_loc coordinates but only the pixel offset from the tile, starting at 0,0.*
deltaWheel changes in a mouse wheel command.*
left, right, middle1 if this button is down or involved in this action, 0 otherwise
shift, ctrl, alt1 if this modifier key is held, 0 otherwise
link1 if the mouse is over a maptext link, 0 otherwise
cellGrid cell involved in a mouse action. In a drag/drop action, src.cell is the dragging cell and over.cell is the drop cell.
drag-cellAlias for src.cell.
drop-cellAlias for over.cell.
* Coordinate values are comma-separated, but you can follow them with .x or .y to get the individual X and Y numbers.

An example mouse macro command might look like this:

my-mousedown-verb [[src]] [[button]] "keys=[[keys as params]];drag=[[drag as params]]"

And the verb to go with it looks like this:

client
    // "in src" is the same as "in usr.client" here
    verb/my_mousedown_verb(object as anything in src, button as text, params as text)

In the example, the src value is a reference such as you would get with the ref() proc. It can be used as a verb argument directly and won’t be enclosed by quotes by default. The button value is a string and the default formatting will put quotes around it. The keys and drag values were given the as params format specifier so they would behave as part of a parameter list.

In drag/drop actions, you can precede any value with src or over if there may be different information for the dragged object and the mouseover object/location. This also applies to things like keys, which by default will be the currently held keys but you can use src.keys to refer to the values from when the drag began.

Available macros

This is a list of all keys and gamepad events that can be used in macros.

Macro modifiers are part of the macro name, and control the conditions in which the macro will fire.
ModifierMeaning
SHIFT+This macro only counts if either Shift key is pressed.
CTRL+This macro only counts if either Ctrl key is pressed.
ALT+This macro only counts if either Alt key is pressed.
+REPIf a key/button is held down, this macro repeats.
+UPThis macro fires when the key/button is released.
Keyboard keys are the garden-variety macros. (This list is abridged to exclude keys probably no one has.)
KeyDescription
A - ZLetter key
0 - 9Number key
Numpad0 - Numpad9Numpad numbers
NorthUp arrow
SouthDown arrow
EastRight arrow
WestLeft arrow
NorthwestHome key
SouthwestEnd key
NortheastPage Up key
SoutheastPage Down key
CenterCenter key (numpad)
ReturnEnter / Return key
EscapeEsc key
TabTab key
SpaceSpace bar
BackBackspace key
InsertIns key
DeleteDel key
PausePause key
SnapshotSnapshot / Print Screen key
LWinLeft Windows key
RWinRight Windows key
AppsApps key
MultiplyMultiply key
AddAdd key
SubtractSubtract key
DivideDivide / Slash key
SeparatorSeparator / Backslash key
ShiftShift key (when not used as a modifier)
CtrlCtrl key (when not used as a modifier)
AltAlt key (when not used as a modifier)
VolumeMuteMute key
VolumeUpVolume up key
VolumeDownVolume down key
MediaPlayPausePlay/pause media key
MediaStopStop media key
MediaNextNext track key
MediaPrevPrevious track key
Special macros
**Any**A special macro that can run a command on press/release of any key or gamepad button. UP is the only modifier allowed. In the command, [[*]] is replaced with the key/button name.*
**GamepadRaw***Captures raw input from a gamepad, without regard to the adjustments done by the Gamepad Setup dialog. In the command, [[id]] is replaced by the name of the button or axis changed (“Button0” through “Button15” and “Axis0” through “Axis11”), [[value]] is replaced with the value of the button or axis, and [[*]] is equivalent to [[id]] [[value]].
* If no gamepad mappings are included in a game’s interface, the default mappings are used instead, which will map the Dpad buttons to the arrow keys. This will cause the Any macro to register both a gamepad directional button and the mapped key on the same press. If you plan on using macros to capture gamepad input, you may wish instead to map any one of the directional buttons to “None”, which will override the default gamepad mappings completely.
Gamepad buttons can use another gamepad button as a modifier (but not CTRL, SHIFT, ALT), and can be mapped to one or two keyboard keys or mouse buttons.
ButtonDescription
GamepadFace1A (Xbox), X (PS), bottom of diamond
GamepadFace2B (Xbox), Circle (PS), right of diamond
GamepadFace3X (Xbox), Square (PS), left of diamond
GamepadFace4Y (Xbox), Triangle (PS), top of diamond
GamepadL1Left top shoulder
GamepadR1Right top shoulder
GamepadL2Left bottom shoulder
GamepadR2Right bottom shoulder
GamepadSelectSelect / Back
GamepadStartStart / Forward
GamepadL3Left analog click
GamepadR3Right analog click
Directional buttons: only one can pressed at a time, and the diagonal buttons are virtual.
GamepadUpUp button
GamepadDownDown button
GamepadLeftLeft button
GamepadRightRight button
GamepadUpLeftUp+left virtual button
GamepadUpRightUp+right virtual button
GamepadDownLeftDown+left virtual button
GamepadDownRightDown+right virtual button
Gamepad analog sticks can have commands and/or map to GamepadDir, GamepadDir4, or Mouse. They can use a gamepad button as a modifier. In a command, [[x]] and [[y]] are replaced by coordinates, and [[*]] is replaced by both with a comma for separation.
GamepadLeftAnalogLeft analog stick
GamepadRightAnalogLeft analog stick
Gamepad Dpads†‡ can have commands or are used as mapping targets for analog sticks. A gamepad button can be used as a modifier. In a command, [[*]] is replaced by a direction number, which can be 0.
GamepadDirDpad, converted to one of the eight standard directions.
GamepadDir4Dpad, converted to a cardinal direction.
All of the gamepad macros defined above apply to the first gamepad. BYOND can now support up to four gamepads, and you can replace Gamepad in the names above with Gamepad2, Gamepad3, or Gamepad4 to access them. Each gamepad also has its own raw macro (i.e., Gamepad2Raw).

If you use a Dpad macro like GamepadDir as a map-to target, you don’t have to specify gamepad 2-4 in map-to; the mapping will automatically know that when Gamepad2LeftAnalog is mapped to GamepadDir, it means Gamepad2Dir.
Mouse macros can have commands but not be used as mapping targets.
MouseDownMouse button pressed (replaces MouseDown verb)
MouseUpMouse button released (replaces MouseUp verb)
MouseClickA click action has occurred (replaces Click verb)
MouseDblClickA double-click action has occurred (replaces DblClick verb)
MouseOverMouse has moved over a new icon or entered/exited a control (replaces MouseEntered and MouseExited verbs)
MouseMoveMouse has moved to a new pixel of the same icon (replaces MouseMove verb)
MouseDragMouse has begin dragging or is over a new drop target (replaces MouseDrag verb)
MouseDragMoveMouse is dragging and is over a new pixel of the same drop target (replaces MouseDrag verb in situations where MouseMove would apply)
MouseDropMouse drag has been released over a target (replaces MouseDrop verb)
MouseWheelA wheel movement has occurred (replaces MouseWheel verb)
Mouse targets can only be used as mapping targets for another macro.
MouseThe mouse cursor, mappable by a gamepad analog stick.
MouseLeftButtonLeft button, mappable by a gamepad button.
MouseRightButtonRight button, mappable by a gamepad button.
MouseMiddleButtonMiddle button, mappable by a gamepad button.

* If no gamepad mappings are included in a game’s interface, the default mappings are used instead, which will map the Dpad buttons to the arrow keys. This will cause the Any macro to register both a gamepad directional button and the mapped key on the same press. If you plan on using macros to capture gamepad input, you may wish instead to map any one of the directional buttons to “None”, which will override the default gamepad mappings completely.

All of the gamepad macros defined above apply to the first gamepad. BYOND can now support up to four gamepads, and you can replace Gamepad in the names above with Gamepad2, Gamepad3, or Gamepad4 to access them. Each gamepad also has its own raw macro (i.e., Gamepad2Raw).

If you use a Dpad macro like GamepadDir as a map-to target, you don’t have to specify gamepad 2-4 in map-to; the mapping will automatically know that when Gamepad2LeftAnalog is mapped to GamepadDir, it means Gamepad2Dir.