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.
-- 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' } })| Function | Notes |
|---|---|
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
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.
| Preset | Goal size | Speed |
|---|---|---|
easy | 0.30 | 0.45 |
medium | 0.20 | 0.65 |
hard | 0.11 | 0.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:
| Field | Meaning |
|---|---|
goalSize | Fraction of the ring that is the goal (0 to 1). |
areaSize | The goal in degrees, used when goalSize is not set. |
speed | Laps per second. |
speedMultiplier | Scales the medium speed, used when speed is not set. |
cursorSize | Cursor width as a fraction of the ring. Default 0.025. |
stages | How many hits this setup needs. Default 1. |
keys | Keys 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.