Calibration
Measures how late this player hears the game’s sound (speakers with a delay of their own, like Bluetooth headphones) or sees its screen, and offers to set their offset to it: it plays clicks (or, measuring Visual, flashes its light in silence) on a steady beat, the player taps along with its TapAction, a click or a touch for a few bars, and it works out how long after each beat the taps came, leaves out the odd ones and offers their average as the Result, which its Apply action makes the player’s Game.AudioOffset (or VisualOffset), kept in their save data. Beat clocks allow for the offset from then on.
It starts as it’s shown (a panel with it opens; see StartOnShow), playing its clicks in place of the music (which comes back when it’s done), and hides the buttons inside it while the player taps, showing them again when it’s done: Entity > Audio > Create Calibration Screen makes a panel with one, its prompt, and Apply, Again and Back buttons, for an options menu’s button to open. It draws its light and a dot for each beat to tap, lit as each tap lands. Its Start, Stop and Apply actions are there for buttons and scripts, its Prompt for a text to say what to do, and its Result, Taps and Current outputs for anything else. It runs in real time, under a pause menu too, and each machine keeps its own in a network game: it measures and sets its own player’s offset, which no other player’s game ever sees.
Works with: Panel (to open it from an options menu); Text (showing its Prompt); BeatClock (which allows for the offset it sets)
Draws itself (its entity draws at Order 310 unless it has a Sprite, whose order counts).
In a network game, each machine keeps its own entity with this on it: it isn’t sent.
Properties
Section titled “Properties”Each is listed as its key in the scene file and the MCP tools, then its kind of value, its default and what it does.
measures: one of Audio, Visual = “Audio”. What it measures: Audio taps along to clicks, Visual to a light flashing in silence. (Field: one of its values.)tempo: a number = 90. Beats a minute of the clicks or flashes: slow enough that a late tap isn’t taken for the next beat’s. (Field: a number.)countIn: a whole number = 4. Beats to listen to (or watch) before the taps count. (Field: a number.)beats: a whole number = 16. Beats to tap along to. Half of them need steady taps for a result. (Field: a number.)startOnShow: true or false = true. Starts as soon as it’s shown (as its panel opens, or the scene starts); off, it waits for its Start action. (Field: on or off.)volume: a number = 1. How loud the clicks are, 0 to 1, on top of the player’s sound volume. (Field: a number.)
Controls
Section titled “Controls”tapAction: text = “Jump”. An input action that taps: Jump is Space and the gamepad’s A. Empty leaves just clicks and touches. Like a menu’s controls, it listens while it’s on the top panel (or no panel is open). (Names an input action.) (Field: a name.)clicks: true or false = true. A click of the left mouse button, or a touch, taps too. (Field: on or off.)
color: a color, “#RRGGBB” or “#RRGGBBAA” = “#F08C2EFF”. The color of its light and of the dots for the beats. (Field: a color.)size: a number = 1.2. How big its light is, in world units (the dots go under it); 0 draws nothing. (Field: a number.)order: a whole number = 310. Higher draws on top, like Sprite.Order (an entity’s sprite says for it). (Field: a number.)
Actions
Section titled “Actions”What anything can make it do with no code: a Trigger’s do when its message arrives, a Contraptions Wire’s input as its signal comes on, a script’s Game.Do(entity, “Name”).
Start. Starts it (again): the clicks or flashes begin, and earlier taps are forgotten.Stop. Stops it without a result, bringing the music back.Apply. Sets the player’s offset to what it measured (kept in their save data), once it has measured something.
Outputs
Section titled “Outputs”What anything can read with no code: a Counter’s, Bar’s or Text’s output, a Contraptions Wire’s output as its signal; Text shows names too, the rest read numbers, true as 1.
IsRunning(true or false). True while the clicks or flashes are going.Taps(a whole number, out of its beats). The taps counted so far, on the beats to tap along to.Result(a number). What it measured, in milliseconds: how long after the beats the steady taps came, on average. Below 0 when they came before. 0 until it’s measured.Spread(a number). How far the steady taps were from their average, in milliseconds: how much to trust the result.Applied(true or false). True once its result has been applied, until it starts again.Current(a number). The player’s offset it measures, as it’s set now, in milliseconds (Game.AudioOffset or VisualOffset).Title(a name). What it sets, for a heading: “Audio Offset” or “Visual Offset”.Prompt(a name). What to tell the player now, for a Text to show (its Output): how to tap, how many taps so far, what it measured and whether to apply it. It names the tap action in braces, so the text shows its key or button.
While the game runs
Section titled “While the game runs”Not saved with the scene; scripts read them, and entity_get shows them as live while the game plays.
state: one of Waiting, Listening, Tapping, Measured, Failed. Where it has got to.isRunning: true or false. True while the clicks or flashes are going.taps: a whole number. The taps counted so far, on the beats to tap along to.result: a number. What it measured, in milliseconds: how long after the beats the steady taps came, on average. Below 0 when they came before. 0 until it’s measured.spread: a number. How far the steady taps were from their average, in milliseconds: how much to trust the result.applied: true or false. True once its result has been applied, until it starts again.current: a number. The player’s offset it measures, as it’s set now, in milliseconds (Game.AudioOffset or VisualOffset).title: text. What it sets, for a heading: “Audio Offset” or “Visual Offset”.prompt: text. What to tell the player now, for a Text to show (its Output): how to tap, how many taps so far, what it measured and whether to apply it. It names the tap action in braces, so the text shows its key or button.
Scripts use it as Calibration: its methods, events and values that aren’t saved with the scene.