KernelAPI reference
Class InputScript
Namespace: MicroEngine.Core
Assembly: MicroEngine.dll
Guide: Testing your game
A deterministic input script, keyed by update number. Text format, one command per line:
# comment30 press confirm # down for 2 updates60 hold right 90 # down for 90 updates60 down jump / 75 up jump # explicit edges200 capture title.png240 touch 1 dpad 1 0 # finger 1 down on the d-pad, one radius to the right (or moves there)250 tap 2 jump # finger 2 taps the "jump" control (lifted 2 updates later)260 touch 3 0.5,0.5 # finger 3 at the middle of the screen (fractions of its size)300 lift 1320 prompts gamepad playstation # name controls as on a PlayStation pad (keyboard, gamepad, touch or auto)400 key Space down # the script's keyboard: a key by position (a Key name) goes down, or up410 keytap Z # down and up within one frame420 pad 2 add playstation # the script's gamepad 2 connects (xbox, playstation or nintendo)430 pad 2 A down # a button of pad 2 (a PadButton name) goes down, or up440 pad 2 LeftX -0.8 # an axis of pad 2 (a PadAxis name) moves450 pad 2 remove460 mouse 160,90 down # the script's mouse moves to a point in canvas pixels (and its button goes down or up)470 wheel 1 # the wheel turns one notch away from the player480 text Ana # text typed (the rest of the line), read while text input is on900 quit“@+N” instead of an absolute number means N updates after the previous command. Touch commands go through the game’s VirtualControls with the same hit testing as real fingers. The device commands send events from the script’s own devices (ScriptKeyboard, ScriptMouse, ScriptPad) through the engine’s input layers, exactly as a backend’s would; each device is announced before its first event.
public sealed class InputScriptInheritance
Constructors
InputScript()
public InputScript()Properties
QuitUpdate
The update after which the script stops the run, or null.
public long? QuitUpdate { get; }Property Value
long?
ScriptKeyboard
The script’s keyboard.
public static DeviceId ScriptKeyboard { get; }Property Value
ScriptMouse
The script’s mouse.
public static DeviceId ScriptMouse { get; }Property Value
Methods
AddPad(long, int, GamepadStyle)
The script’s gamepad number connects at update at.
public InputScript AddPad(long at, int number, GamepadStyle style = GamepadStyle.Xbox)Parameters
at long
number int
style GamepadStyle
Returns
Apply(long, InputMap)
Applies every edge scheduled for the update about to run.
public void Apply(long update, InputMap input)Parameters
update long
input InputMap
ApplyDevices(long, InputSystem)
Sends the device events scheduled for the update about to run to input (routed with the frame’s events).
public void ApplyDevices(long update, InputSystem input)Parameters
update long
input InputSystem
ApplyPrompts(long, ActionPrompts)
Applies the prompts commands scheduled for the update about to run: which device prompts names controls for.
public void ApplyPrompts(long update, ActionPrompts prompts)Parameters
update long
prompts ActionPrompts
ApplyTouches(long, VirtualControls)
Hands the touches scheduled for the update about to run to the game’s touch controls.
public void ApplyTouches(long update, VirtualControls controls)Parameters
update long
controls VirtualControls
Axis(long, int, PadAxis, float)
An axis of the script’s gamepad number moves to value (the pad connects first if it has not).
public InputScript Axis(long at, int number, PadAxis axis, float value)Parameters
at long
number int
axis PadAxis
value float
Returns
Button(long, int, PadButton, bool)
A button of the script’s gamepad number goes down or up (the pad connects first if it has not).
public InputScript Button(long at, int number, PadButton button, bool down)Parameters
at long
number int
button PadButton
down bool
Returns
Capture(long, string)
Saves a screenshot named fileName after update at.
public InputScript Capture(long at, string fileName)Parameters
at long
fileName string
Returns
CaptureAt(long)
The screenshot file name scheduled after update, or null.
public string? CaptureAt(long update)Parameters
update long
Returns
Hold(long, string, long)
Holds action down from update at for duration updates (at least 1).
public InputScript Hold(long at, string action, long duration)Parameters
at long
action string
duration long
Returns
Key(long, Key, bool)
The script’s keyboard presses (down) or releases key at update at.
public InputScript Key(long at, Key key, bool down)Parameters
at long
key Key
down bool
Returns
Lift(long, int)
Lifts finger finger at update at.
public InputScript Lift(long at, int finger)Parameters
at long
finger int
Returns
Mouse(long, Vector2, bool?)
The script’s mouse moves to position (canvas pixels) and, when down is set, its primary button goes down or up.
public InputScript Mouse(long at, Vector2 position, bool? down = null)Parameters
at long
position Vector2
down bool?
Returns
Parse(string)
Parses the text format described above.
public static InputScript Parse(string text)Parameters
text string
Returns
Exceptions
A line is invalid; the message names its line number.
Press(long, string)
Presses action at update at for 2 updates.
public InputScript Press(long at, string action)Parameters
at long
action string
Returns
QuitAfter(long)
Stops the run after update at.
public InputScript QuitAfter(long at)Parameters
at long
Returns
QuitAt(long)
Whether the run must stop after update.
public bool QuitAt(long update)Parameters
update long
Returns
ScriptPad(int)
The script’s gamepad number (1 and up).
public static DeviceId ScriptPad(int number)Parameters
number int
Returns
Send(long, InputEvent)
Sends e at update at, through the input layers like a device’s event (its device must be announced, as a backend’s must).
public InputScript Send(long at, InputEvent e)Parameters
at long
Returns
Touch(long, int, string, Vector2)
Puts finger finger on a touch control (offset in its radii) at update at, or moves it there.
public InputScript Touch(long at, int finger, string control, Vector2 offset = default)Parameters
at long
finger int
control string
offset Vector2