module
Eagle::Script
Overview
Schedules synthetic input over time: key presses, clicks, drags and gamepad events.
Scripts drive integration tests, attract-mode demos and replays. Events go through
exactly the same path as real input, so Input, App#input and every node see them.
Times are seconds since the first step was scheduled.
Script.at(0.5) { Script.click(v2(100, 100)) }
Script.at(1.0) { Script.type("hello"); Script.key(Key::Enter) }
Script.drag(v2(10, 10), v2(200, 200), seconds: 0.5, start: 2.0)
Script.hold(Key::Right, 1.5, start: 3.0) # walk right for a moment
Defined in:
eagle/core/script.crClass Method Summary
-
.at(seconds : Number, &block : -> ) : Nil
Runs the block when the script clock reaches seconds.
-
.clear : Nil
Cancels every pending step and resets the clock.
-
.click(at : Vec2, button : MouseButton = MouseButton::Left, clicks : Int32 = 1) : Nil
Moves the mouse to at and clicks.
-
.connect_gamepad(id : Int32 = 0) : Nil
Simulates plugging in a gamepad.
-
.drag(from : Vec2, to : Vec2, seconds : Number = 0.5, start : Number = 0, steps : Int32 = 10, button : MouseButton = MouseButton::Left) : Nil
Schedules a full drag: press at from, move in steps increments over seconds, then release at to.
-
.drop_file(path : String) : Nil
Simulates dropping a file onto the window.
-
.gamepad_axis(id : Int32, axis : GamepadAxis, value : Number) : Nil
Moves a gamepad axis to value (-1 to 1).
-
.gamepad_button(id : Int32, b : GamepadButton) : Nil
Presses and releases a gamepad button.
-
.hold(k : Key, seconds : Number, start : Number = 0) : Nil
Holds a key down for seconds, starting at script time start.
-
.key(k : Key, mods : KeyMod = KeyMod::None) : Nil
--- convenience emitters (queue events for the next frame) --- Presses and releases a key on the next frame.
-
.key_down(k : Key, mods : KeyMod = KeyMod::None) : Nil
Presses a key and keeps it held until
.key_up. -
.key_up(k : Key, mods : KeyMod = KeyMod::None) : Nil
Releases a key.
-
.move(to : Vec2) : Nil
Moves the mouse to to.
-
.pending : Int32
Number of steps still waiting to run.
-
.press(at : Vec2, button : MouseButton = MouseButton::Left) : Nil
Moves to at and presses a mouse button without releasing it.
-
.release(at : Vec2, button : MouseButton = MouseButton::Left) : Nil
Moves to at and releases a mouse button.
-
.running? : Bool
True while steps remain.
-
.time : Float64
Seconds since the script started.
-
.type(text : String) : Nil
Types text, as if entered on the keyboard.
-
.wheel(delta : Vec2, at : Vec2 = Input.mouse) : Nil
Scrolls the wheel by delta.
Class Method Detail
Runs the block when the script clock reaches seconds.
Moves the mouse to at and clicks. Pass clicks: 2 for a double-click.
Schedules a full drag: press at from, move in steps increments over seconds, then release at to. Starts at script time start.
Moves a gamepad axis to value (-1 to 1).
Presses and releases a gamepad button.
Holds a key down for seconds, starting at script time start.
--- convenience emitters (queue events for the next frame) --- Presses and releases a key on the next frame.
Moves to at and presses a mouse button without releasing it.
Moves to at and releases a mouse button.