Skip to content

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:

C#
# comment
30 press confirm # down for 2 updates
60 hold right 90 # down for 90 updates
60 down jump / 75 up jump # explicit edges
200 capture title.png
240 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 1
320 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 up
410 keytap Z # down and up within one frame
420 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 up
440 pad 2 LeftX -0.8 # an axis of pad 2 (a PadAxis name) moves
450 pad 2 remove
460 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 player
480 text Ana # text typed (the rest of the line), read while text input is on
900 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.

C#
public sealed class InputScript

Inheritance

object ← InputScript

Constructors

InputScript()

C#
public InputScript()

Properties

QuitUpdate

The update after which the script stops the run, or null.

C#
public long? QuitUpdate { get; }

Property Value

long?

ScriptKeyboard

The script’s keyboard.

C#
public static DeviceId ScriptKeyboard { get; }

Property Value

DeviceId

ScriptMouse

The script’s mouse.

C#
public static DeviceId ScriptMouse { get; }

Property Value

DeviceId

Methods

AddPad(long, int, GamepadStyle)

The script’s gamepad number connects at update at.

C#
public InputScript AddPad(long at, int number, GamepadStyle style = GamepadStyle.Xbox)

Parameters

at long

number int

style GamepadStyle

Returns

InputScript

Apply(long, InputMap)

Applies every edge scheduled for the update about to run.

C#
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).

C#
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.

C#
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.

C#
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).

C#
public InputScript Axis(long at, int number, PadAxis axis, float value)

Parameters

at long

number int

axis PadAxis

value float

Returns

InputScript

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).

C#
public InputScript Button(long at, int number, PadButton button, bool down)

Parameters

at long

number int

button PadButton

down bool

Returns

InputScript

Capture(long, string)

Saves a screenshot named fileName after update at.

C#
public InputScript Capture(long at, string fileName)

Parameters

at long

fileName string

Returns

InputScript

CaptureAt(long)

The screenshot file name scheduled after update, or null.

C#
public string? CaptureAt(long update)

Parameters

update long

Returns

string?

Hold(long, string, long)

Holds action down from update at for duration updates (at least 1).

C#
public InputScript Hold(long at, string action, long duration)

Parameters

at long

action string

duration long

Returns

InputScript

Key(long, Key, bool)

The script’s keyboard presses (down) or releases key at update at.

C#
public InputScript Key(long at, Key key, bool down)

Parameters

at long

key Key

down bool

Returns

InputScript

Lift(long, int)

Lifts finger finger at update at.

C#
public InputScript Lift(long at, int finger)

Parameters

at long

finger int

Returns

InputScript

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.

C#
public InputScript Mouse(long at, Vector2 position, bool? down = null)

Parameters

at long

position Vector2

down bool?

Returns

InputScript

Parse(string)

Parses the text format described above.

C#
public static InputScript Parse(string text)

Parameters

text string

Returns

InputScript

Exceptions

FormatException

A line is invalid; the message names its line number.

Press(long, string)

Presses action at update at for 2 updates.

C#
public InputScript Press(long at, string action)

Parameters

at long

action string

Returns

InputScript

QuitAfter(long)

Stops the run after update at.

C#
public InputScript QuitAfter(long at)

Parameters

at long

Returns

InputScript

QuitAt(long)

Whether the run must stop after update.

C#
public bool QuitAt(long update)

Parameters

update long

Returns

bool

ScriptPad(int)

The script’s gamepad number (1 and up).

C#
public static DeviceId ScriptPad(int number)

Parameters

number int

Returns

DeviceId

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).

C#
public InputScript Send(long at, InputEvent e)

Parameters

at long

e InputEvent

Returns

InputScript

Touch(long, int, string, Vector2)

Puts finger finger on a touch control (offset in its radii) at update at, or moves it there.

C#
public InputScript Touch(long at, int finger, string control, Vector2 offset = default)

Parameters

at long

finger int

control string

offset Vector2

Returns

InputScript