Skip to content

Skill checks ​

A timing mini game: a cursor sweeps a ring and the player presses a key while it is inside the goal zone. tm.skillCheck is client only, blocks the calling thread, and returns true when every stage was passed or false on a miss, a cancel or an interruption.

lua
-- one stage, medium difficulty, the E key
if tm.skillCheck('medium') then unlockDoor() end

-- three stages of rising difficulty
local ok = tm.skillCheck({ 'easy', 'medium', 'hard' })

-- custom setup and keys
local ok = tm.skillCheck({ 'easy', { goalSize = 0.15, speed = 0.9 } }, { 'w', 'a', 's', 'd' })

-- one explicit setup with three stages
local ok = tm.skillCheck({ goalSize = 0.25, speed = 0.7, stages = 3, keys = { 'e' } })
FunctionNotes
tm.skillCheck(difficulties, inputs?)Runs the check and waits.
tm.skillCheckActive()true while one is on screen.
tm.cancelSkillCheck()Cancels it, which counts as failed. Returns whether one was running.

Only one runs at a time. Starting a second returns false and logs a warning.

Difficulties ​

Skill check (press the shown key)Open full size

difficulties is a preset name, a list of them (one stage per entry), or a single setup table. A list can mix names and setup tables.

PresetGoal sizeSpeed
easy0.300.45
medium0.200.65
hard0.110.85

Goal size is the fraction of the ring that counts as a hit, and speed is ring laps per second. An unknown name logs a warning and uses medium.

A setup table takes:

FieldMeaning
goalSizeFraction of the ring that is the goal (0 to 1).
areaSizeThe goal in degrees, used when goalSize is not set.
speedLaps per second.
speedMultiplierScales the medium speed, used when speed is not set.
cursorSizeCursor width as a fraction of the ring. Default 0.025.
stagesHow many hits this setup needs. Default 1.
keysKeys to ask for (only for the single table form; otherwise use inputs).

Neighboring stages with the same setup are shown as one run with stage dots, instead of restarting for each stage.

Keys ​

inputs is a list of key names, for example { 'w', 'a', 's', 'd' }. These are the keys the player may be asked to press. The default is { 'e' }.

While it runs ​

Looking around and every attack input stay locked until the check ends. The cursor is not shown and the mouse is not used. The lock loop runs once per frame and exits the moment the check ends.