Skip to main content

Module script

Module script 

Source
Expand description

Input scripts: the steps of a player’s input a tool plays (keys, controller buttons, an action by name, waits in seconds, the crank, and the debug view’s channels turned on) and the one plan that turns them into frames of raw input events (frames). The Harness plays a Script (Script::play, the harness feature), the live link’s server plays a Play request’s steps, and a capture plan’s input steps are these (ticket 2566): a key press is written once.

A step’s form is the same in JSON and in RON: {"keys": "Enter Up"}, {"pad": "South+East"}, {"act": "Confirm"}, {"wait": 0.5}, {"crank": 30}, {"debug": "grid"}; keys("Enter Up") and so on in a plan’s RON.

Every frame is FRAME_DT long, and a wait is played as wait_frames of them. How long one wait may be is the player’s to say, not the step’s: harness::MAX_WAIT, link::MAX_WAIT, a capture plan’s MAX_WAIT.

Structs§

Script
Steps played in order.

Enums§

Planned
Frames of a script’s plan.
Press
What presses an action: a key chord, or a button (or two together).
Step
One step of a script, played in the order written.

Constants§

FRAME_DT
How long each frame of a script is: a 60th of a second.

Functions§

check_waits
Whether every wait of steps is at most max seconds, the most the player plays in one step; an error names the step.
frames
The frames steps give, each FRAME_DT long, with the game’s keymap (for an action by name) and buttons pressed on a pad of kind pad: a key chord or a pad token down in one frame and up in the next, an action as its key or its button, a wait as wait_frames frames with no input (none for a wait of 0). An error names the step (step 3: act: …): one Step::check refuses, an action that can’t be pressed, or a crank, which isn’t played this way (the Harness winds it itself; the live link can’t yet).
press_for
What presses the game’s action named name in keymap: its primary key (Keymap::primary), else its primary button (Keymap::primary_button). The one lookup of an action by name, so every tool presses an action as a player would. An error names the action: the game has none of that name, or it has neither a key nor a button.
pressable
The names of keymap’s actions that have a key or a button, in ActionSet::ALL’s order: those an Step::Act can press.
wait_frames
How many frames a wait of seconds takes: the seconds at 60 a second, rounded up, a product within a thousandth of a whole number counting as that number (0.5 s is 30 frames, 1/60 s is 1, 0.51 s is 31). A wait above 0 is at least one frame; a wait of 0, or one that isn’t a number of seconds 0 or more, is none.