Module impostor.original

Return initial data for Config

Config

Config.reset () Restores default configuration settings.
Config.save () Saves the current configuration.
Config.load () Loads saved configuration.

Context

Context.initial_data () Gets initial data for Context.
Context.reset () Resets game context to initial state.
Context.new_game () Starts a new game.
Context.save_game () Saves the current game state.
Context.load_game () Loads a saved game state.
Context.initial_data_debug_asc (level) Returns Context.initial_data() overridden for the given ascension level.
Context.new_game_debug (level) Starts the game at the given ascension level (defaults to ContextDebug.asc_level).

AsciiArt.draw (text, options) Draws ASCII art text using rectangles.
RLE.draw (runs, values) Draws an RLE-encoded image.
Audio.music_play (track[, tempo]) Plays track at optional speed.
MysteriousManScreen.start ([options]) Starts the mysterious man screen.
MysteriousManScreen.set_text (new_text) Sets the scrolling text content.
meter_on_complete If set, called with elapsed_sec instead of Meter.on_minigame_complete()

Util

Util.safeindex (array, index) Safely wraps an index for an array.
Util.go_to_screen_by_id (screen_id) Navigates to a screen by its ID.
Util.contains (t, value) Checks if a table contains a specific value.
Util.deepcopy (orig, seen) Deep copies tables

Print

Print.text (text, x, y, color[, fixed[, scale]]) Prints text with shadow.
Print.text_contour (text, x, y, color[, fixed[, scale[, contour_color]]]) Prints text with a contour (outline) instead of shadow.
Print.text_center (text, x, y, color[, fixed[, scale]]) Prints centered text with shadow.
Print.text_center_contour (text, x, y, color[, fixed[, scale[, contour_color]]]) Prints centered text with contour instead of shadow.

Input

Input.up () Checks if Up is pressed.
Input.down () Checks if Down is pressed.
Input.left () Checks if Left is pressed.
Input.right () Checks if Right is pressed.
Input.select () Checks if Select is pressed.
Input.back () Checks if Back is pressed.
Input.enter () Checks if Enter is pressed.
Input.up_repeat () Checks if Up is pressed or held (with repeat).
Input.down_repeat () Checks if Down is pressed or held (with repeat).

TextInput

TextInput.init (max_len) Initialises a new text input session.
TextInput.next_letter () Advances to the next letter at the cursor position (wraps Z→A).
TextInput.prev_letter () Goes back to the previous letter at the cursor position (wraps A→Z).
TextInput.select_letter () Confirms the current letter and advances the cursor to the next position.
TextInput.next_position () Moves the cursor one position to the right (stops at last position).
TextInput.prev_position () Moves the cursor one position to the left (stops at first position).
TextInput.get_name () Returns the assembled name string.
TextInput.get_position () Returns the current 1-based cursor position.
TextInput.get_letter (i) Returns the letter at the given 1-based position.
TextInput.is_done () Returns true when all positions have been confirmed.

Mouse

Mouse.update () Updates mouse state.
Mouse.x () Returns current mouse X position.
Mouse.y () Returns current mouse Y position.
Mouse.clicked () Returns true if the mouse button was just pressed this frame (and not yet consumed).
Mouse.held () Returns true if the mouse button is held down.
Mouse.consume () Marks the current click as consumed so Mouse.clicked() won't fire again this frame.
Mouse.in_rect (x, y, w, h) Returns true if the mouse is within the given rectangle.
Mouse.in_circle (cx, cy, r) Returns true if the mouse is within the given circle.
Mouse.zone (rect) Returns true if the mouse was clicked inside the given rectangle, and consumes the click.
Mouse.zone_circle (circle) Returns true if the mouse was clicked inside the given circle, and consumes the click.

Ascension

Ascension.get_initial () Gets initial ascension state.
Ascension.get_level () Gets the current ascension level.
Ascension.get_max_level () Gets the maximum ascension level.
Ascension.increase () Increases the ascension level by 1, clamped to the max.
Ascension.did_increase () Returns true if ascension was incremented since the last consume call.
Ascension.consume_increase () Consumes the increase flag, returning its value and resetting it.
Ascension.is_complete () Returns true when the ascension meter is fully complete (level 10).
Ascension.draw (x, y, options) Draws the ascension meter as individual letters of "ASCENSION".
Ascension.get_fade_color () Returns the current fade-in color based on progress through the palette.
Ascension.start_fade () Starts the fade-in effect for the most recently gained letter.
Ascension.start_flash () Starts the ascension flash effect.
Ascension.draw_flash () Updates and draws the ascension flash overlay.
Ascension.update_fade () Updates the fade-in timer.
Ascension.is_flashing () Returns whether a flash effect is currently active.
Ascension.is_fading () Returns whether the fade-in effect is currently active.

Meter

Meter.get_initial () Gets initial meter values.
Meter.hide () Hides meters.
Meter.show () Shows meters.
Meter.get_max () Gets max meter value.
Meter.set_decay (amount) Sets the decay amount applied to all meters per day.
Meter.get_decay_percentage () Gets the meter decay as a percentage of the max meter value.
Meter.get_combo_multiplier () Gets combo multiplier.
Meter.update () Updates all meters.
Meter.add (key, amount) Adds amount to a meter.
Meter.on_minigame_complete (is_work) Called on minigame completion.
Meter.apply_ddr_reward (mistake_count) Meter changes after DDR: uses max-meter percentages; combo advances like other work minigames.
Meter.apply_wakeup_reward (elapsed_sec) Meter changes for the wake-up button mash: faster completion is better for WPM.
Meter.apply_coworker_discussion_reward () Random single meter shift after finishing a coworker discussion: ISM +10%, WPM −10%, or BM +10%.
Meter.apply_sumphore_discussion_reward () After finishing a sumphore discussion: reduce whichever of ISM / WPM / BM is highest by 10% of max (stable tie to ISM, then WPM, then BM).
Meter.draw () Draws meters.
Meter.draw_ascension_only () Draws only the ascension letters at the same position as in Meter.draw().

Focus

Focus.start (cx, cy[, params]) Starts a focus overlay that reveals content through an expanding circle.
Focus.close (cx, cy[, params]) Starts a closing focus overlay that hides content by shrinking the visible circle.
Focus.start_driven (cx, cy[, params]) Starts a driven focus overlay whose radius is controlled externally via Focus.set_percentage().
Focus.set_percentage (pct) Sets the visible radius as a percentage of the full screen extent.
Focus.is_active () Checks whether the focus overlay is currently active.
Focus.stop () Stops the focus overlay immediately.
Focus.update () Updates the focus overlay animation.
Focus.draw () Draws the focus overlay (black screen with circular cutout).

Day

Day.increase () Increases the day count and triggers registered handlers.
Day.register_handler (handler) Registers a handler to be called when the day increases.

Timer

Timer.get_initial () Gets initial timer values.
Timer.set_duration (frames) Sets the number of frames for one full timer revolution.
Timer.update () Updates the timer and handles revolution events.
Timer.draw () Draws the clock timer indicator as a circular progress bar.

Trigger

Trigger.register (trigger)
Trigger.get_by_id (id)
Trigger.get_all ()
Trigger.is_active (id)
Trigger.start (id) If already active, restarts from 0.
Trigger.stop (id)
Trigger.reset (id) Resets elapsed time to 0 without calling handlers.
Trigger.update () Pauses during minigames.

Minigame

Minigame.draw_win_overlay (win_text) Draws a unified win message overlay.

Glitch

Glitch.show () Shows the glitch effect.
Glitch.hide () Hides the glitch effect.
Glitch.draw () Draws the glitch effect if active.

CommuteGlitch

CommuteGlitch.get_level () Gets the current commute glitch level.
CommuteGlitch.increment () Increments the glitch counter.
CommuteGlitch.reset () Resets the glitch counter and hides the glitch overlay.
CommuteGlitch.enter_truth () Jumps to glitch level 7 (full corruption).
CommuteGlitch.is_active () Returns true when ascension level is 7 or 8 (ASCENSIO/N steps active).
CommuteGlitch.is_max () Returns true when commute glitch is at max level (7).
CommuteGlitch.music_speed () Returns the music playback speed for the current glitch level.
CommuteGlitch.corrupt_sprite_list (list) Returns a corrupted copy of a sprite drawable list.
CommuteGlitch.draw_sprite_list (list) Draws a sprite list, applying a PALETTE MAP remap for norman_echo entries.
CommuteGlitch.draw_background_flicker () Draws a random tile-flicker effect over the background (glitch level 7).

CodeGenerator

CodeGenerator.encode_pair (n) Encodes a number (0–935) as exactly 2 base-36 characters.
CodeGenerator.decode_pair (s) Decodes 2 base-36 characters back to a number.
CodeGenerator.encrypt (text) Encrypts a player name into a code twice its length.
CodeGenerator.decrypt (encrypted_text) Decrypts a personal code back to the original player name.

Discussion

Discussion.register (discussion) Registers a discussion definition.
Discussion.get_by_id (id) Gets a discussion by ID.
Discussion.start (id, return_window[, start_step]) Starts a discussion, switching to the discussion window.
Discussion.get_current_step () Gets the current step data for the active discussion.
Discussion.go_to_step (next_step) Advances to a specific step or ends the discussion.
Discussion.finish () Ends the active discussion and returns to the previous window.

UI

UI.draw_top_bar (title) Draws the top bar.
UI.draw_menu (items, selected_item, x, y[, centered[, scroll_offset[, visible_count]]]) Draws a menu.
UI.update_menu (items, selected_item[, x[, y[, centered[, scroll_offset[, visible_count]]]]]) Updates menu selection.
UI.word_wrap (text, max_chars_per_line) Wraps text.

Audio

Audio.music_stop () Stops current music.
Audio.music_play_mainmenu () Plays main menu music.
Audio.music_play_mystery () Plays mystery man music.
Audio.music_play_wakingup () Plays waking up music.
Audio.music_play_room_morning () Plays room morning music.
Audio.music_play_room_street_1 () Plays room street 1 music.
Audio.music_play_room_street_2 () Plays room street 2 music.
Audio.music_play_room_ () Plays room music.
Audio.music_play_room_work (tempo) Plays room work music.
Audio.music_play_activity_work () Plays activity work music.
Audio.sfx_select () Plays select sound effect.
Audio.sfx_deselect () Plays deselect sound effect.
Audio.sfx_beep () Plays beep sound effect.
Audio.sfx_success () Plays success sound effect.
Audio.sfx_bloop () Plays bloop sound effect.
Audio.sfx_alarm () Plays alarm sound effect
Audio.sfx_drum_low () Plays drum sound effect.
Audio.sfx_drum_high () Plays drum sound effect.
Audio.sfx_arrowhit (note) Plays sound effect for arrow hit

Songs

frame_from_beat (beat, bpm[, fps]) Converts beats to frames.
beats_to_pattern (beats, bpm, fps) Converts beat notation to frame pattern.

Sprite

Sprite.register (sprite_data) Registers a sprite definition.
Sprite.generate_table (width, height, starting_s, x_base, y_base, x_step, y_step) Generates a sprites table for a rectangular composite sprite.
Sprite.draw_list (sprite_list) Immediately draws a list of sprites
Sprite.list_randomize (sprite_ids, positions) Given a list of sprite IDs (or sprite entries with correction offsets) and a list of possible positions, randomly assigns each sprite to a unique position and returns a drawable list.
Sprite.show (id, x, y[, colorkey[, scale[, flip_x[, flip_y[, rot]]]]]) Schedules a sprite for drawing.
Sprite.hide (id) Hides a displayed sprite.
Sprite.draw_at (id, x, y[, colorkey[, scale[, flip_x[, flip_y[, rot]]]]]) Draws a sprite immediately without scheduling it.
Sprite.draw () Draws all scheduled sprites.

Decision

Decision.register (decision) Registers a decision definition.
Decision.get_label (decision) Gets the display label for a decision.
Decision.get_by_id (id) Gets a decision by ID.
Decision.get_all () Gets all registered decisions.
Decision.get_for_screen (screen_data) Gets decision objects based on a screen's data.
Decision.filter_available (decisions_list) Filters a list of decision objects based on their condition function.
Decision.draw (decisions, selected_decision_index) Draws decision selector.
Decision.update (decisions, selected_decision_index) Updates decision selector.

Map

Map.get_maps_array () Gets all registered maps as an array.
Map.register (map_data) Registers a map definition.
Map.get_by_id (map_id) Gets a map by ID.
Map.draw (map_id) Draws a map.

Screen

Screen.register (screen_data) Registers a screen definition.
Screen.get_by_id (screen_id) Gets a screen by ID.
Screen.get_all () Gets all registered screens.

Window

Window.register (id, window_table) Registers a window table.
Window.get (id) Retrieves a registered window table by its ID.
Window.set_current (id) Sets the currently active window.
Window.get_current_id () Gets the ID of the currently active window.
Window.get_current_handler () Gets the handler function for the currently active window.

GameOverWindow

GameOverWindow.show (reason) Shows the game over screen.
GameOverWindow.draw () Draws the game over screen.
GameOverWindow.update () Updates the game over screen logic.

EndWindow

EndWindow.draw () Draws the end screen window.
EndWindow.update () Updates the end screen logic.

TitleIntroWindow

TitleIntroWindow.draw () Draws the title intro window.
TitleIntroWindow.update () Updates the title intro window logic.

TTGIntroWindow

TTGIntroWindow.draw () Draws the TTG intro window.
TTGIntroWindow.update () Updates the TTG intro window logic.

BriefIntroWindow

BriefIntroWindow.draw () Draws the brief intro window.
BriefIntroWindow.update () Updates the brief intro window logic.

MenuWindow

MenuWindow.calc_menu_x () Calculates the animated x position of the menu block.
MenuWindow.draw_header () Draws the header with title and separator.
MenuWindow.draw_norman () Draws the 4x scaled Norman sprite on the left side of the screen.
MenuWindow.ensure_visible () Adjusts _scroll_offset so the selected item is within the visible window.
MenuWindow.draw () Draws the menu window.
MenuWindow.update () Updates the menu window logic.
MenuWindow.new_game () Opens player name entry then starts a new game.
MenuWindow.save_game () Saves the current game from the menu.
MenuWindow.resume_game () Resumes the game from the menu.
MenuWindow.exit () Exits the game.
MenuWindow.controls () Opens the controls screen.
MenuWindow.player_name () Opens the player name entry screen (test mode shortcut).
MenuWindow.credits () Opens the credits screen.
MenuWindow.audio_test () Opens the audio test menu.
MenuWindow.continued () Opens the continued screen.
MenuWindow.end_screen () Opens the end screen for testing.
MenuWindow.ddr_test () Opens the DDR minigame test.
MenuWindow.ascend_debug () Opens the ASCEND debug start window.
MenuWindow.level_up_flash () Triggers the Level Up flash animation for testing.
MenuWindow.refresh_menu_items () Refreshes the list of menu items based on current game state.

ControlsWindow

ControlsWindow.draw () Draws the controls window.
ControlsWindow.update () Updates the controls window logic.

AudioTestWindow

AudioTestWindow.generate_menuitems (list_func, index_func) Generates menu items for audio test.
AudioTestWindow.generate_listfunc () Generates list of audio functions.
AudioTestWindow.back () Navigates back from audio test window.
AudioTestWindow.init () Initializes audio test window.
AudioTestWindow.draw () Draws audio test window.
AudioTestWindow.update () Updates audio test window logic.

AscendDebugWindow

AscendDebugWindow.init () Initialises the ASCEND debug start window.
AscendDebugWindow.draw () Draws the ASCEND debug start window.
AscendDebugWindow.update () Updates the ASCEND debug start window logic.

PopupWindow

PopupWindow.show (content_strings) Displays a popup window.
PopupWindow.hide () Hides the popup window.
PopupWindow.update () Updates popup window logic.
PopupWindow.draw () Draws the popup window.

MinigameButtonMashWindow

MinigameButtonMashWindow.init_context () Gets initial button mash minigame configuration.
MinigameButtonMashWindow.init (params) Initializes button mash minigame state.
MinigameButtonMashWindow.start (return_window[, params]) Starts the button mash minigame.
MinigameButtonMashWindow.update () Updates button mash minigame logic.
MinigameButtonMashWindow.draw () Draws button mash minigame.

MinigameRhythmWindow

MinigameRhythmWindow.init_context () Gets initial rhythm minigame configuration.
MinigameRhythmWindow.init (params) Initializes rhythm minigame state.
MinigameRhythmWindow.start (return_window[, params]) Starts the rhythm minigame.
MinigameRhythmWindow.update () Updates rhythm minigame logic.
MinigameRhythmWindow.draw () Draws rhythm minigame.

MinigameDDRWindow

MinigameDDRWindow.draw_background () Background drawing for DDR minigame.
MinigameDDRWindow.init_context () Gets initial DDR minigame configuration.
MinigameDDRWindow.prepareSong (song, generated_length, special_mode) Builds song data (and optional generated pattern) for the minigame.
MinigameDDRWindow.on_arrow_hit_special (game_context) Handles hit feedback and special-mode scoring for one arrow.
MinigameDDRWindow.on_end (game_context) Ends the minigame: win timer, sfx, and special-mode pass/fail bookkeeping.
MinigameDDRWindow.init (params) Initializes DDR minigame state.
MinigameDDRWindow.start (return_window[, song_key[, params]]) Starts the DDR minigame.
MinigameDDRWindow.update () Updates DDR minigame logic.
MinigameDDRWindow.draw () Draws DDR minigame.

DiscussionWindow

DiscussionWindow.draw () Draws the discussion window.
DiscussionWindow.update () Updates the discussion window logic.

ContinuedWindow

ContinuedWindow.draw () Draws the continued window.
ContinuedWindow.update () Updates the continued window logic.

CreditsWindow

CreditsWindow.init () Initialises credits state and pre-computes character metrics.
CreditsWindow.draw () Draws the credits window.
CreditsWindow.update () Updates credits window logic.

PlayerNameWindow

PlayerNameWindow.init (on_confirm) Initialises the player name window.
PlayerNameWindow.draw () Draws the player name window.
PlayerNameWindow.update () Updates player name window logic.

GameWindow

GameWindow.draw () Draws the game window.
GameWindow.draw_with_underlay (underlay_draw) Draws the game window with a custom underlay.
GameWindow.update () Updates the game window logic.
GameWindow.set_state (new_state) Sets the active window.

Main

TIC () Main game loop (TIC-80 callback).


Config

Config.reset ()
Restores default configuration settings.
Config.save ()
Saves the current configuration.
Config.load ()
Loads saved configuration.

Context

Context.initial_data ()
Gets initial data for Context.

Returns:

    result table Initial context data or nil.
    Fields:
    * current_menu_item (number) Index of the currently selected menu item.
    * popup (table) Popup window state. Contains: `show` (boolean) whether popup is visible, `content` (table) array of strings to display.
    * game_in_progress (boolean) Whether a game is currently active.
    * minigame_ddr (table) DDR minigame state (see Minigame.get_default_ddr).
    * minigame_button_mash (table) Button mash minigame state (see Minigame.get_default_button_mash).
    * minigame_rhythm (table) Rhythm minigame state (see Minigame.get_default_rhythm).
    * meters (table) Meter values (see Meter.get_initial).
    * ascension (table) Ascension meter state (see Ascension.get_initial).
    * triggers (table) Active trigger runtime state, keyed by trigger ID.
    * stat_screen_active (boolean) Whether the stat screen overlay is currently shown.
    * have_met_sumphore (boolean) Whether the player has talked to the homeless guy.
    * have_been_to_office (boolean) Whether the player has been to the office.
    * have_done_work_today (boolean) Whether the player has done work today.
    * toilet_meters_today_morning (boolean) Whether the home (before work) toilet meter delta was already applied this day.
    * toilet_meters_today_evening (boolean) Whether the home (after work) toilet meter delta was already applied this day.
    * coworker_discussion_meter_applied_today (boolean) Whether the daily coworker discussion meter roll was already applied this day.
    * sumphore_discussion_meter_applied_today (boolean) Whether the daily sumphore discussion meter roll was already applied this day.
    * game (table) Current game progress state. Contains: `current_screen` (string) active screen ID
Context.reset ()
Resets game context to initial state.
Context.new_game ()
Starts a new game.
Context.save_game ()
Saves the current game state.
Context.load_game ()
Loads a saved game state.
Context.initial_data_debug_asc (level)
Returns Context.initial_data() overridden for the given ascension level.

Parameters:

  • level number Target ascension level (0..Ascension.get_max_level()).

Returns:

    table Debug-patched initial context data.
Context.new_game_debug (level)
Starts the game at the given ascension level (defaults to ContextDebug.asc_level). Wire this to a key or call it directly; do not use Context.new_game() when debugging.

Parameters:

  • level number|nil Target ascension level.

AsciiArt.draw (text, options)
Draws ASCII art text using rectangles.

Parameters:

  • text string The ASCII art text to draw.
  • options table Configuration options (char_w, char_h, line_gap, word_gap, color, x, y).
RLE.draw (runs, values)
Draws an RLE-encoded image.

Parameters:

  • runs table Array of run lengths.
  • values table Array of pixel values (colors).
Audio.music_play (track[, tempo])
Plays track at optional speed. Doesn't restart if track and speed are unchanged.

Parameters:

  • track number Track index.
  • tempo number TIC-80 music speed override (-1 = default). (optional)
MysteriousManScreen.start ([options])
Starts the mysterious man screen.

Parameters:

  • options table Optional configuration.
    Fields:
    * text (string) Override for the scrolling text.
    * day_text (string) Override for the centered day label.
    * on_text_complete (function) Callback fired once when the text phase ends.
    * skip_text (boolean) If true, skip the text phase and go straight to day display.
    (optional)
MysteriousManScreen.set_text (new_text)
Sets the scrolling text content.

Parameters:

  • new_text string The text to display.
meter_on_complete
If set, called with elapsed_sec instead of Meter.on_minigame_complete()

Util

Util.safeindex (array, index)
Safely wraps an index for an array.

Parameters:

  • array table The array to index.
  • index number The desired index (can be out of bounds).

Returns:

    number index The wrapped index within the array's bounds.
Util.go_to_screen_by_id (screen_id)
Navigates to a screen by its ID.

Parameters:

  • screen_id string The ID of the screen to go to.
Util.contains (t, value)
Checks if a table contains a specific value.

Parameters:

  • t table The table to check.
  • value any The value to look for.

Returns:

    boolean true if the value is found, false otherwise.
Util.deepcopy (orig, seen)
Deep copies tables

Parameters:

  • orig any The value to deep copy.
  • seen any Used for recursive calls to handle loops

Returns:

    any any The copied object

Print

Print.text (text, x, y, color[, fixed[, scale]])
Prints text with shadow.

Parameters:

  • text string The text to print.
  • x number The x-coordinate.
  • y number The y-coordinate.
  • color number The color of the text.
  • fixed boolean If true, uses fixed-width font.
    (optional)
  • scale number The scaling factor.
    (optional)
Print.text_contour (text, x, y, color[, fixed[, scale[, contour_color]]])
Prints text with a contour (outline) instead of shadow.

Parameters:

  • text string The text to print.
  • x number The x-coordinate.
  • y number The y-coordinate.
  • color number The color of the text.
  • fixed boolean If true, uses fixed-width font.
    (optional)
  • scale number The scaling factor (also used for outline thickness).
    (optional)
  • contour_color number Outline color; defaults to black; if equal to text color, uses white.
    (optional)
Print.text_center (text, x, y, color[, fixed[, scale]])
Prints centered text with shadow.

Parameters:

  • text string The text to print.
  • x number The x-coordinate for centering.
  • y number The y-coordinate.
  • color number The color of the text.
  • fixed boolean If true, uses fixed-width font.
    (optional)
  • scale number The scaling factor.
    (optional)
Print.text_center_contour (text, x, y, color[, fixed[, scale[, contour_color]]])
Prints centered text with contour instead of shadow.

Parameters:

  • text string The text to print.
  • x number The x-coordinate for centering.
  • y number The y-coordinate.
  • color number The color of the text.
  • fixed boolean If true, uses fixed-width font.
    (optional)
  • scale number The scaling factor.
    (optional)
  • contour_color number Outline color; defaults to black; if equal to text color, uses white.
    (optional)

Input

Input.up ()
Checks if Up is pressed.
Input.down ()
Checks if Down is pressed.
Input.left ()
Checks if Left is pressed.
Input.right ()
Checks if Right is pressed.
Input.select ()
Checks if Select is pressed.
Input.back ()
Checks if Back is pressed.
Input.enter ()
Checks if Enter is pressed.
Input.up_repeat ()
Checks if Up is pressed or held (with repeat).
Input.down_repeat ()
Checks if Down is pressed or held (with repeat).

TextInput

TextInput.init (max_len)
Initialises a new text input session.

Parameters:

  • max_len number Maximum character count (default 3).
TextInput.next_letter ()
Advances to the next letter at the cursor position (wraps Z→A).
TextInput.prev_letter ()
Goes back to the previous letter at the cursor position (wraps A→Z).
TextInput.select_letter ()
Confirms the current letter and advances the cursor to the next position. When called on the last position the cursor moves into the done state.
TextInput.next_position ()
Moves the cursor one position to the right (stops at last position).
TextInput.prev_position ()
Moves the cursor one position to the left (stops at first position). Also steps back out of the done state.
TextInput.get_name ()
Returns the assembled name string.

Returns:

    string
TextInput.get_position ()
Returns the current 1-based cursor position.

Returns:

    number
TextInput.get_letter (i)
Returns the letter at the given 1-based position.

Parameters:

  • i number

Returns:

    string
TextInput.is_done ()
Returns true when all positions have been confirmed.

Returns:

    boolean

Mouse

Mouse.update ()
Updates mouse state. Call once per frame.
Mouse.x ()
Returns current mouse X position.
Mouse.y ()
Returns current mouse Y position.
Mouse.clicked ()
Returns true if the mouse button was just pressed this frame (and not yet consumed).
Mouse.held ()
Returns true if the mouse button is held down.
Mouse.consume ()
Marks the current click as consumed so Mouse.clicked() won't fire again this frame.
Mouse.in_rect (x, y, w, h)
Returns true if the mouse is within the given rectangle.

Parameters:

  • x number Left edge.
  • y number Top edge.
  • w number Width.
  • h number Height.
Mouse.in_circle (cx, cy, r)
Returns true if the mouse is within the given circle.

Parameters:

  • cx number Center x.
  • cy number Center y.
  • r number Radius.
Mouse.zone (rect)
Returns true if the mouse was clicked inside the given rectangle, and consumes the click.

Parameters:

  • rect table A table with fields: x, y, w, h.
Mouse.zone_circle (circle)
Returns true if the mouse was clicked inside the given circle, and consumes the click.

Parameters:

  • circle table A table with fields: x, y, r.

Ascension

Ascension.get_initial ()
Gets initial ascension state.

Returns:

    result table Initial ascension state.
    Fields:
    * level (number) Current ascension level (0-9).
Ascension.get_level ()
Gets the current ascension level.

Returns:

    number The current ascension level (0-9).
Ascension.get_max_level ()
Gets the maximum ascension level.

Returns:

    number The maximum ascension level.
Ascension.increase ()
Increases the ascension level by 1, clamped to the max.
Ascension.did_increase ()
Returns true if ascension was incremented since the last consume call.

Returns:

    boolean Whether ascension increased this cycle.
Ascension.consume_increase ()
Consumes the increase flag, returning its value and resetting it.

Returns:

    boolean Whether ascension had increased this cycle.
Ascension.is_complete ()
Returns true when the ascension meter is fully complete (level 10).

Returns:

    boolean Whether the cycle can be broken.
Ascension.draw (x, y, options)
Draws the ascension meter as individual letters of "ASCENSION". Each letter lights up per level. Drawn beneath existing meter bars.

Parameters:

  • x number Left x position.
  • y number Top y position.
  • options table Optional overrides: lit_color, dim_color, spacing.
Ascension.get_fade_color ()
Returns the current fade-in color based on progress through the palette.

Returns:

    number The palette color index for the current fade step.
Ascension.start_fade ()
Starts the fade-in effect for the most recently gained letter.
Ascension.start_flash ()
Starts the ascension flash effect.
Ascension.draw_flash ()
Updates and draws the ascension flash overlay. Call once per frame from the main loop.
Ascension.update_fade ()
Updates the fade-in timer. Call once per frame from the main loop.
Ascension.is_flashing ()
Returns whether a flash effect is currently active.

Returns:

    boolean Whether the flash is playing.
Ascension.is_fading ()
Returns whether the fade-in effect is currently active.

Returns:

    boolean Whether the letter fade-in is playing.

Meter

Meter.get_initial ()
Gets initial meter values.

Returns:

    result table Initial meter values.
    Fields:
    * ism (number) Initial ISM meter value.
    * wpm (number) Initial WPM meter value.
    * bm (number) Initial BM meter value.
    * combo (number) Current combo count.
    * combo_timer (number) Frames since last combo action.
    * hidden (boolean) Whether meters are hidden.
Meter.hide ()
Hides meters.
Meter.show ()
Shows meters.
Meter.get_max ()
Gets max meter value.

Returns:

    number The maximum meter value.
Meter.set_decay (amount)
Sets the decay amount applied to all meters per day.

Parameters:

  • amount number Amount to subtract from each meter.
Meter.get_decay_percentage ()
Gets the meter decay as a percentage of the max meter value.

Returns:

    number The decay percentage per day.
Meter.get_combo_multiplier ()
Gets combo multiplier.

Returns:

    number The current combo multiplier.
Meter.update ()
Updates all meters.
Meter.add (key, amount)
Adds amount to a meter.

Parameters:

  • key string The meter key (e.g., "wpm", "ism", "bm").
  • amount number The amount to add.
Meter.on_minigame_complete (is_work)
Called on minigame completion.

Parameters:

  • is_work boolean If true (work-style minigame), apply combo to WPM/ISM/BM and advance combo. DDR uses `Meter.apply_ddr_reward` instead. Otherwise flat equal gain, combo unchanged.
Meter.apply_ddr_reward (mistake_count)
Meter changes after DDR: uses max-meter percentages; combo advances like other work minigames. 0 mistakes: WPM −10%, ISM +5%, BM +5%. 1–3: WPM −5%, ISM +10%, BM +10%. More than 3: WPM unchanged, ISM +10%, BM +10%.

Parameters:

  • mistake_count number Total mistakes (missed arrows, wrong inputs, and special-mode rule violations).
Meter.apply_wakeup_reward (elapsed_sec)
Meter changes for the wake-up button mash: faster completion is better for WPM. Perfect: under 2s — WPM +20%. Good: 2–3s — WPM +10%, ISM +5%, BM +5%. Bad: over 3s — WPM −5%, ISM +10%, BM +10%.

Parameters:

  • elapsed_sec number Seconds from minigame start until the bar was filled.
Meter.apply_coworker_discussion_reward ()
Random single meter shift after finishing a coworker discussion: ISM +10%, WPM −10%, or BM +10%.
Meter.apply_sumphore_discussion_reward ()
After finishing a sumphore discussion: reduce whichever of ISM / WPM / BM is highest by 10% of max (stable tie to ISM, then WPM, then BM).
Meter.draw ()
Draws meters.
Meter.draw_ascension_only ()
Draws only the ascension letters at the same position as in Meter.draw(). Used when meters are hidden but ascension letters still need to be visible.

Focus

Focus.start (cx, cy[, params])
Starts a focus overlay that reveals content through an expanding circle.

Parameters:

  • cx number The x-coordinate of the circle center.
  • cy number The y-coordinate of the circle center.
  • params table Optional parameters: `speed` (number) expansion rate in pixels/frame, `initial_radius` (number) starting radius in pixels (default 0), `on_complete` (function) callback when overlay disperses. (optional)
Focus.close (cx, cy[, params])
Starts a closing focus overlay that hides content by shrinking the visible circle.

Parameters:

  • cx number The x-coordinate of the circle center.
  • cy number The y-coordinate of the circle center.
  • params table Optional parameters: `speed` (number) shrink rate in pixels/frame, `on_complete` (function) callback when screen is fully covered. (optional)
Focus.start_driven (cx, cy[, params])
Starts a driven focus overlay whose radius is controlled externally via Focus.set_percentage(). The radius maps linearly from initial_radius (at 0%) to the screen corner distance (at 100%).

Parameters:

  • cx number The x-coordinate of the circle center.
  • cy number The y-coordinate of the circle center.
  • params table Optional parameters: `initial_radius` (number) radius at 0% (default 0). (optional)
Focus.set_percentage (pct)
Sets the visible radius as a percentage of the full screen extent. Only has effect when the overlay is in driven mode (started via Focus.start_driven).

Parameters:

  • pct number A value from 0 to 1 (0 = initial_radius, 1 = full screen).
Focus.is_active ()
Checks whether the focus overlay is currently active.

Returns:

    boolean Whether the focus overlay is active.
Focus.stop ()
Stops the focus overlay immediately.
Focus.update ()
Updates the focus overlay animation. No-op in driven mode.
Focus.draw ()
Draws the focus overlay (black screen with circular cutout). Must be called after all other drawing to appear on top of every visual layer.

Day

Day.increase ()
Increases the day count and triggers registered handlers.
Day.register_handler (handler)
Registers a handler to be called when the day increases.

Parameters:

  • handler function The function to call when the day increases.

Timer

Timer.get_initial ()
Gets initial timer values.

Returns:

    result table Initial timer values.
    Fields:
    * progress (number) Clock timer revolution progress (0 to 1).
Timer.set_duration (frames)
Sets the number of frames for one full timer revolution.

Parameters:

  • frames number Frames per revolution.
Timer.update ()
Updates the timer and handles revolution events.
Timer.draw ()
Draws the clock timer indicator as a circular progress bar.

Trigger

Trigger.register (trigger)

Parameters:

  • trigger table The trigger data table.
    • id string Unique trigger identifier.
    • duration number Duration in frames before the trigger fires.
    • on_start function Called when the trigger starts. Defaults to noop. (optional)
    • on_stop function Called when the trigger fires or is manually stopped. Defaults to noop. (optional)
    • repeating boolean If true, trigger restarts after firing. Defaults to false. (optional)
Trigger.get_by_id (id)

Parameters:

  • id string The trigger ID.

Returns:

    table|nil result The trigger definition or nil.
Trigger.get_all ()

Returns:

    table result All trigger definitions keyed by ID.
Trigger.is_active (id)

Parameters:

  • id string The trigger ID.

Returns:

    boolean active True if the trigger is running.
Trigger.start (id)
If already active, restarts from 0.

Parameters:

  • id string The trigger ID.
Trigger.stop (id)

Parameters:

  • id string The trigger ID.
Trigger.reset (id)
Resets elapsed time to 0 without calling handlers. No-op if inactive.

Parameters:

  • id string The trigger ID.
Trigger.update ()
Pauses during minigames.

Minigame

Minigame.draw_win_overlay (win_text)
Draws a unified win message overlay.

Parameters:

  • win_text

Glitch

Glitch.show ()
Shows the glitch effect.
Glitch.hide ()
Hides the glitch effect.
Glitch.draw ()
Draws the glitch effect if active.

CommuteGlitch

CommuteGlitch.get_level ()
Gets the current commute glitch level. At ascension level 8+, always returns 7 (max) regardless of stored value.

Returns:

    number Current glitch level (0-7).
CommuteGlitch.increment ()
Increments the glitch counter. Called on each office screen init at asc level 7. Caps at 6; use enter_truth() to reach 7.
CommuteGlitch.reset ()
Resets the glitch counter and hides the glitch overlay. Called when going home.
CommuteGlitch.enter_truth ()
Jumps to glitch level 7 (full corruption). Called by go_to_truth.
CommuteGlitch.is_active ()
Returns true when ascension level is 7 or 8 (ASCENSIO/N steps active).

Returns:

    boolean Whether the commute glitch system is active.
CommuteGlitch.is_max ()
Returns true when commute glitch is at max level (7).

Returns:

    boolean Whether the commute glitch is at max level.
CommuteGlitch.music_speed ()
Returns the music playback speed for the current glitch level. TIC-80 default speed is 6; each step past 1 adds 2.

Returns:

    number Speed value for music().
CommuteGlitch.corrupt_sprite_list (list)
Returns a corrupted copy of a sprite drawable list. Applies flip_y and norman_echo id replacements based on glitch level. Entries marked norman_echo should be drawn via draw_sprite_list for palette change handling.

Parameters:

  • list table Drawable sprite list from Sprite.list_randomize.

Returns:

    table Corrupted copy of the list.
CommuteGlitch.draw_sprite_list (list)
Draws a sprite list, applying a PALETTE MAP remap for norman_echo entries. Uses poke4 to remap ECHO_SRC → ECHO_DST before drawing echoes, then restores.

Parameters:

  • list table Drawable sprite list (may contain mixed normal and echo entries).
CommuteGlitch.draw_background_flicker ()
Draws a random tile-flicker effect over the background (glitch level 7). Every 3 frames draws 6 random 8x8 rects in random palette colors.

CodeGenerator

CodeGenerator.encode_pair (n)
Encodes a number (0–935) as exactly 2 base-36 characters.

Parameters:

  • n
CodeGenerator.decode_pair (s)
Decodes 2 base-36 characters back to a number.

Parameters:

  • s
CodeGenerator.encrypt (text)
Encrypts a player name into a code twice its length. Each input character (A-Z, value 0-25) is encoded as c + SALTS[i] * 26, producing 2 base-36 output characters.

Parameters:

  • text string NAME_LEN-character uppercase player name.

Returns:

    string Encrypted code (2 * NAME_LEN base-36 characters).
CodeGenerator.decrypt (encrypted_text)
Decrypts a personal code back to the original player name.

Parameters:

  • encrypted_text string The code to decrypt (2 * NAME_LEN chars).

Returns:

    string Original player name, or "???" if the code is invalid.

Discussion

Discussion.register (discussion)
Registers a discussion definition.

Parameters:

  • discussion table The discussion data table.
    • id string Unique discussion identifier.
    • steps table Array of step tables, each with `question` (string) and `answers` (array of {label, next_step} tables).
    • on_end function Called when the discussion ends. Defaults to noop. (optional)
Discussion.get_by_id (id)
Gets a discussion by ID.

Parameters:

  • id string The discussion ID.

Returns:

    table|nil result The discussion table or nil.
Discussion.start (id, return_window[, start_step])
Starts a discussion, switching to the discussion window.

Parameters:

  • id string The discussion ID to start.
  • return_window string The window ID to return to after the discussion.
  • start_step number The step index to start from (defaults to 1). (optional)
Discussion.get_current_step ()
Gets the current step data for the active discussion.

Returns:

    table|nil result The current step table or nil.
Discussion.go_to_step (next_step)
Advances to a specific step or ends the discussion.

Parameters:

  • next_step number|nil The step index to go to, or nil to end.
Discussion.finish ()
Ends the active discussion and returns to the previous window.

UI

UI.draw_top_bar (title)
Draws the top bar.

Parameters:

  • title string The title text to display.
UI.draw_menu (items, selected_item, x, y[, centered[, scroll_offset[, visible_count]]])
Draws a menu. Items with header=true are drawn as non-selectable section headers in small font.

Parameters:

  • items table A table of menu items.
  • selected_item number The index of the currently selected item.
  • x number The x-coordinate for the menu (ignored if centered is true).
  • y number The y-coordinate for the menu.
  • centered boolean Whether to center the menu block horizontally. Defaults to false.
    (optional)
  • scroll_offset number 0-based index of the first visible item. Defaults to 0.
    (optional)
  • visible_count number Maximum number of items to draw. Defaults to all.
    (optional)
UI.update_menu (items, selected_item[, x[, y[, centered[, scroll_offset[, visible_count]]]]])
Updates menu selection. Skips items with header=true during navigation.

Parameters:

  • items table A table of menu items.
  • selected_item number The current index of the selected item.
  • x number Menu x position (required for mouse support).
    (optional)
  • y number Menu y position (required for mouse support).
    (optional)
  • centered boolean Whether the menu is centered horizontally.
    (optional)
  • scroll_offset number 0-based index of the first visible item. Defaults to 0.
    (optional)
  • visible_count number Number of visible items (for mouse hit zones). Defaults to all.
    (optional)

Returns:

  1. number selected_item The updated index of the selected item.
  2. boolean mouse_confirmed True if the user clicked on a menu item.
UI.word_wrap (text, max_chars_per_line)
Wraps text.

Parameters:

  • text string The text to wrap.
  • max_chars_per_line number The maximum characters per line.

Returns:

    result table A table of wrapped lines.

Audio

Audio.music_stop ()
Stops current music.
Audio.music_play_mainmenu ()
Plays main menu music.
Audio.music_play_mystery ()
Plays mystery man music.
Audio.music_play_wakingup ()
Plays waking up music.
Audio.music_play_room_morning ()
Plays room morning music.
Audio.music_play_room_street_1 ()
Plays room street 1 music.
Audio.music_play_room_street_2 ()
Plays room street 2 music.
Audio.music_play_room_ ()
Plays room music.
Audio.music_play_room_work (tempo)
Plays room work music. Speed scales with commute glitch level when active.

Parameters:

  • tempo
Audio.music_play_activity_work ()
Plays activity work music.
Audio.sfx_select ()
Plays select sound effect.
Audio.sfx_deselect ()
Plays deselect sound effect.
Audio.sfx_beep ()
Plays beep sound effect.
Audio.sfx_success ()
Plays success sound effect.
Audio.sfx_bloop ()
Plays bloop sound effect.
Audio.sfx_alarm ()
Plays alarm sound effect
Audio.sfx_drum_low ()
Plays drum sound effect.
Audio.sfx_drum_high ()
Plays drum sound effect.
Audio.sfx_arrowhit (note)
Plays sound effect for arrow hit

Parameters:

  • note string The note for the sound to play

Songs

frame_from_beat (beat, bpm[, fps])
Converts beats to frames.

Parameters:

  • beat number The beat number.
  • bpm number Beats per minute.
  • fps number Frames per second (default: 60). (optional)

Returns:

    number The corresponding frame number.
beats_to_pattern (beats, bpm, fps)
Converts beat notation to frame pattern.

Parameters:

  • beats table A table of beat data, e.g., {{1, "left"}, {2, "down"}}.
    • 1 number The beat number.
    • 2 string Arrow direction ("left", "down", "up", or "right").
  • bpm number Beats per minute.
  • fps number Frames per second (default: 60). (optional)

Returns:

    result table The generated pattern or nil.
    Fields:
    * frame (number) The frame number when the arrow should spawn.
    * dir (string) Arrow direction ("left", "down", "up", or "right").

Sprite

Sprite.register (sprite_data)
Registers a sprite definition.

Parameters:

  • sprite_data table A table containing the sprite definition.
    • id string Unique sprite identifier.
    • s number Sprite index for single-sprite mode.
      (optional)
    • colorkey number Default color index for transparency.
      (optional)
    • scale number Default scaling factor.
      (optional)
    • flip_x number Set to 1 to flip horizontally by default.
      (optional)
    • flip_y number Set to 1 to flip vertically by default.
      (optional)
    • rot number Default rotation in degrees.
      (optional)
    • sprites table Array of sub-sprite tables for composite sprites. Each entry has: `s` (number) sprite index, `x_offset` (number) horizontal offset, `y_offset` (number) vertical offset, and optional `colorkey`, `scale`, `flip_x`, `flip_y`, `rot` overrides.
      (optional)
Sprite.generate_table (width, height, starting_s, x_base, y_base, x_step, y_step)
Generates a sprites table for a rectangular composite sprite.

Parameters:

  • width number The number of sprites wide.
  • height number The number of sprites tall.
  • starting_s number The sprite index of the top-left tile.
  • x_base number The base x-offset for the leftmost column.
  • y_base number The base y-offset for the topmost row.
  • x_step number The x-offset increment per column.
  • y_step number The y-offset increment per row.

Returns:

    table The sprites table array.
Sprite.draw_list (sprite_list)
Immediately draws a list of sprites

Parameters:

  • sprite_list table An array of tables, each containing: `id` (string) sprite identifier, `x` (number) x-coordinate, `y` (number) y-coordinate, and optional `colorkey`, `scale`, `flip_x`, `flip_y`, `rot` parameters.
Sprite.list_randomize (sprite_ids, positions)
Given a list of sprite IDs (or sprite entries with correction offsets) and a list of possible positions, randomly assigns each sprite to a unique position and returns a drawable list.

Parameters:

  • sprite_ids table An array of sprite identifier values or tables. Each entry may be either: - string: sprite ID to draw. - table: { sprite_id = string, x_correct = number, y_correct = number }.
  • positions table An array of tables, each containing `x` and `y` fields for possible sprite positions.
Sprite.show (id, x, y[, colorkey[, scale[, flip_x[, flip_y[, rot]]]]])
Schedules a sprite for drawing.

Parameters:

  • id string The unique identifier of the sprite.
  • x number The x-coordinate.
  • y number The y-coordinate.
  • colorkey number The color index for transparency.
    (optional)
  • scale number The scaling factor.
    (optional)
  • flip_x number Set to 1 to flip horizontally.
    (optional)
  • flip_y number Set to 1 to flip vertically.
    (optional)
  • rot number The rotation in degrees.
    (optional)
Sprite.hide (id)
Hides a displayed sprite.

Parameters:

  • id string The unique identifier of the sprite.
Sprite.draw_at (id, x, y[, colorkey[, scale[, flip_x[, flip_y[, rot]]]]])
Draws a sprite immediately without scheduling it.

Parameters:

  • id string The unique identifier of the sprite.
  • x number The x-coordinate.
  • y number The y-coordinate.
  • colorkey number The color index for transparency.
    (optional)
  • scale number The scaling factor.
    (optional)
  • flip_x number Set to 1 to flip horizontally.
    (optional)
  • flip_y number Set to 1 to flip vertically.
    (optional)
  • rot number The rotation in degrees.
    (optional)
Sprite.draw ()
Draws all scheduled sprites.

Decision

Decision.register (decision)
Registers a decision definition.

Parameters:

  • decision table The decision data table.
    • id string Unique decision identifier.
    • label string|function Display text for the decision, or a function returning it.
    • condition function Returns true if decision is available. Defaults to always true. (optional)
    • handle function Called when the decision is selected. Defaults to noop. (optional)
Decision.get_label (decision)
Gets the display label for a decision.

Parameters:

  • decision table The decision data table.

Returns:

    string result The resolved decision label.
Decision.get_by_id (id)
Gets a decision by ID.

Parameters:

  • id string The ID of the decision.

Returns:

    table|nil result The decision table or nil.
    Fields:
    * id (string) Unique decision identifier.
    * label (string) Display text for the decision.
    * condition (function) Returns true if decision is available.
    * handle (function) Called when the decision is selected.
Decision.get_all ()
Gets all registered decisions.

Returns:

    result table A table of all registered decisions, indexed by their IDs.
    Fields:
    * id (string) Unique decision identifier.
    * label (string) Display text for the decision.
    * condition (function) Returns true if decision is available.
    * handle (function) Called when the decision is selected.
Decision.get_for_screen (screen_data)
Gets decision objects based on a screen's data.

Parameters:

  • screen_data table The data for the screen.
    • decisions table Array of decision ID strings.

Returns:

    result table An array of decision objects relevant to the screen or nil.
    Fields:
    * id (string) Unique decision identifier.
    * label (string) Display text for the decision.
    * condition (function) Returns true if decision is available.
    * handle (function) Called when the decision is selected.
Decision.filter_available (decisions_list)
Filters a list of decision objects based on their condition function.

Parameters:

  • decisions_list table A table of decision objects.

Returns:

    result table An array of decisions for which condition() is true or nil.
    Fields:
    * id (string) Unique decision identifier.
    * label (string) Display text for the decision.
    * condition (function) Returns true if decision is available.
    * handle (function) Called when the decision is selected.
Decision.draw (decisions, selected_decision_index)
Draws decision selector.

Parameters:

  • decisions table A table of decision items.
  • selected_decision_index number The index of the selected decision.
Decision.update (decisions, selected_decision_index)
Updates decision selector.

Parameters:

  • decisions table A table of decision items.
  • selected_decision_index number The current index of the selected decision.

Returns:

  1. number selected_decision_index The updated index of the selected decision.
  2. boolean mouse_confirmed True if the user clicked the center to confirm.

Map

Map.get_maps_array ()
Gets all registered maps as an array.

Returns:

    result table An array of registered map data.
    Fields:
    * id (string) Unique map identifier.
    * from_x (number) Source tile X coordinate in the map sheet.
    * from_y (number) Source tile Y coordinate in the map sheet.
    * width (number) Width in tiles.
    * height (number) Height in tiles.
    * to_x (number) Destination X coordinate on screen.
    * to_y (number) Destination Y coordinate on screen.
Map.register (map_data)
Registers a map definition.

Parameters:

  • map_data table The map data table.
    • id string Unique map identifier.
    • from_x number Source tile X coordinate in the map sheet.
    • from_y number Source tile Y coordinate in the map sheet.
    • width number Width in tiles.
    • height number Height in tiles.
    • to_x number Destination X coordinate on screen.
    • to_y number Destination Y coordinate on screen.
Map.get_by_id (map_id)
Gets a map by ID.

Parameters:

  • map_id string The ID of the map.

Returns:

    result table The map data table or nil.
    Fields:
    * id (string) Unique map identifier.
    * from_x (number) Source tile X coordinate in the map sheet.
    * from_y (number) Source tile Y coordinate in the map sheet.
    * width (number) Width in tiles.
    * height (number) Height in tiles.
    * to_x (number) Destination X coordinate on screen.
    * to_y (number) Destination Y coordinate on screen.
Map.draw (map_id)
Draws a map.

Parameters:

  • map_id string The ID of the map to draw.

Screen

Screen.register (screen_data)
Registers a screen definition.

Parameters:

  • screen_data table The screen data table.
    • id string Unique screen identifier.
    • name string Display name of the screen.
    • decisions table Array of decision ID strings available on this screen.
    • background string Map ID used as background.
    • init function Called when the screen is entered. Defaults to noop. (optional)
    • update function Called each frame while screen is active. Defaults to noop. (optional)
    • draw function Called after the focus overlay to draw screen-specific overlays. Defaults to noop. (optional)
Screen.get_by_id (screen_id)
Gets a screen by ID.

Parameters:

  • screen_id string The ID of the screen.

Returns:

    table|nil screen The screen table or nil.
    Fields:
    * id (string) Unique screen identifier.
    * name (string) Display name.
    * decisions (table) Array of decision ID strings.
    * background (string) Map ID used as background.
    * init (function) Called when the screen is entered.
    * update (function) Called each frame while screen is active.
Screen.get_all ()
Gets all registered screens.

Returns:

    result table A table containing all registered screen data, indexed by their IDs or nil.
    Fields:
    * id (string) Unique screen identifier.
    * name (string) Display name of the screen.
    * decisions (table) Array of decision ID strings available on this screen.
    * background (string) Map ID used as background.
    * init (function) Called when the screen is entered.
    * update (function) Called each frame while screen is active.

Window

Window.register (id, window_table)
Registers a window table.

Parameters:

  • id string The ID of the window (e.g., "splash", "menu").
  • window_table table The actual window module table (e.g., GameWindow).
Window.get (id)
Retrieves a registered window table by its ID.

Parameters:

  • id string The ID of the window.

Returns:

    result table The window module table or nil.
    Fields:
    * update (function) Called each frame to update window logic.
    * draw (function) Called each frame to draw the window.
Window.set_current (id)
Sets the currently active window.

Parameters:

  • id string The ID of the window to activate.
Window.get_current_id ()
Gets the ID of the currently active window. This function is used by the main game loop to update and draw the active window.

Returns:

    string The ID of the active window.
Window.get_current_handler ()
Gets the handler function for the currently active window. This function is used by the main game loop to update and draw the active window.

Returns:

    function A function that updates and draws the current window.

GameOverWindow

GameOverWindow.show (reason)
Shows the game over screen.

Parameters:

  • reason string One of "ism", "bm", "days".
GameOverWindow.draw ()
Draws the game over screen.
GameOverWindow.update ()
Updates the game over screen logic.

EndWindow

EndWindow.draw ()
Draws the end screen window.
EndWindow.update ()
Updates the end screen logic.

TitleIntroWindow

TitleIntroWindow.draw ()
Draws the title intro window.
TitleIntroWindow.update ()
Updates the title intro window logic.

TTGIntroWindow

TTGIntroWindow.draw ()
Draws the TTG intro window.
TTGIntroWindow.update ()
Updates the TTG intro window logic.

BriefIntroWindow

BriefIntroWindow.draw ()
Draws the brief intro window.
BriefIntroWindow.update ()
Updates the brief intro window logic.

MenuWindow

MenuWindow.calc_menu_x ()
Calculates the animated x position of the menu block.

Returns:

    number x The left edge x coordinate for the menu.
MenuWindow.draw_header ()
Draws the header with title and separator.
MenuWindow.draw_norman ()
Draws the 4x scaled Norman sprite on the left side of the screen.
MenuWindow.ensure_visible ()
Adjusts _scroll_offset so the selected item is within the visible window.
MenuWindow.draw ()
Draws the menu window.
MenuWindow.update ()
Updates the menu window logic.
MenuWindow.new_game ()
Opens player name entry then starts a new game.
MenuWindow.save_game ()
Saves the current game from the menu.
MenuWindow.resume_game ()
Resumes the game from the menu.
MenuWindow.exit ()
Exits the game.
MenuWindow.controls ()
Opens the controls screen.
MenuWindow.player_name ()
Opens the player name entry screen (test mode shortcut).
MenuWindow.credits ()
Opens the credits screen.
MenuWindow.audio_test ()
Opens the audio test menu.
MenuWindow.continued ()
Opens the continued screen.
MenuWindow.end_screen ()
Opens the end screen for testing.
MenuWindow.ddr_test ()
Opens the DDR minigame test.
MenuWindow.ascend_debug ()
Opens the ASCEND debug start window.
MenuWindow.level_up_flash ()
Triggers the Level Up flash animation for testing.
MenuWindow.refresh_menu_items ()
Refreshes the list of menu items based on current game state.

ControlsWindow

ControlsWindow.draw ()
Draws the controls window.
ControlsWindow.update ()
Updates the controls window logic.

AudioTestWindow

AudioTestWindow.generate_menuitems (list_func, index_func)
Generates menu items for audio test.

Parameters:

  • list_func table List of audio functions.
  • index_func number Current index of selected function.

Returns:

    result table Generated menu items, an array of menu item tables or nil.
    Fields:
    * label (string) Display text for the menu item.
    * decision (function) Called when the menu item is selected.
AudioTestWindow.generate_listfunc ()
Generates list of audio functions.

Returns:

    result table A sorted list of audio function names.
AudioTestWindow.back ()
Navigates back from audio test window.
AudioTestWindow.init ()
Initializes audio test window.
AudioTestWindow.draw ()
Draws audio test window.
AudioTestWindow.update ()
Updates audio test window logic.

AscendDebugWindow

AscendDebugWindow.init ()
Initialises the ASCEND debug start window.
AscendDebugWindow.draw ()
Draws the ASCEND debug start window.
AscendDebugWindow.update ()
Updates the ASCEND debug start window logic.

PopupWindow

PopupWindow.show (content_strings)
Displays a popup window.

Parameters:

  • content_strings table A table of strings to display in the popup.
PopupWindow.hide ()
Hides the popup window.
PopupWindow.update ()
Updates popup window logic.
PopupWindow.draw ()
Draws the popup window.

MinigameButtonMashWindow

MinigameButtonMashWindow.init_context ()
Gets initial button mash minigame configuration.

Returns:

    MinigameButtonMashState
MinigameButtonMashWindow.init (params)
Initializes button mash minigame state.

Parameters:

  • params table Optional parameters for configuration.
MinigameButtonMashWindow.start (return_window[, params])
Starts the button mash minigame.

Parameters:

  • return_window string The window ID to return to after the minigame.
  • params table Optional parameters for minigame configuration.
    (optional)
MinigameButtonMashWindow.update ()
Updates button mash minigame logic.
MinigameButtonMashWindow.draw ()
Draws button mash minigame.

MinigameRhythmWindow

MinigameRhythmWindow.init_context ()
Gets initial rhythm minigame configuration.

Returns:

    result table The default rhythm minigame configuration.
MinigameRhythmWindow.init (params)
Initializes rhythm minigame state.

Parameters:

  • params table Optional parameters for configuration.
MinigameRhythmWindow.start (return_window[, params])
Starts the rhythm minigame.

Parameters:

  • return_window string The window ID to return to after the minigame.
  • params table Optional parameters for minigame configuration.
    (optional)
MinigameRhythmWindow.update ()
Updates rhythm minigame logic.
MinigameRhythmWindow.draw ()
Draws rhythm minigame.

MinigameDDRWindow

MinigameDDRWindow.draw_background ()
Background drawing for DDR minigame.
MinigameDDRWindow.init_context ()
Gets initial DDR minigame configuration.

Returns:

    MinigameDDRState
MinigameDDRWindow.prepareSong (song, generated_length, special_mode)
Builds song data (and optional generated pattern) for the minigame.

Parameters:

  • song
  • generated_length
  • special_mode
MinigameDDRWindow.on_arrow_hit_special (game_context)
Handles hit feedback and special-mode scoring for one arrow.

Parameters:

  • game_context MinigameDDRState
MinigameDDRWindow.on_end (game_context)
Ends the minigame: win timer, sfx, and special-mode pass/fail bookkeeping.

Parameters:

  • game_context
MinigameDDRWindow.init (params)
Initializes DDR minigame state.

Parameters:

  • params table Optional parameters for configuration.
MinigameDDRWindow.start (return_window[, song_key[, params]])
Starts the DDR minigame.

Parameters:

  • return_window string The window ID to return to after the minigame.
  • song_key string The key of the song to play.
    (optional)
  • params table Optional parameters for minigame configuration.
    (optional)
MinigameDDRWindow.update ()
Updates DDR minigame logic.
MinigameDDRWindow.draw ()
Draws DDR minigame.

DiscussionWindow

DiscussionWindow.draw ()
Draws the discussion window.
DiscussionWindow.update ()
Updates the discussion window logic.

ContinuedWindow

ContinuedWindow.draw ()
Draws the continued window.
ContinuedWindow.update ()
Updates the continued window logic.

CreditsWindow

CreditsWindow.init ()
Initialises credits state and pre-computes character metrics.
CreditsWindow.draw ()
Draws the credits window.
CreditsWindow.update ()
Updates credits window logic.

PlayerNameWindow

PlayerNameWindow.init (on_confirm)
Initialises the player name window.

Parameters:

  • on_confirm function Called with the entered name when the player saves.
PlayerNameWindow.draw ()
Draws the player name window.
PlayerNameWindow.update ()
Updates player name window logic.

GameWindow

GameWindow.draw ()
Draws the game window.
GameWindow.draw_with_underlay (underlay_draw)
Draws the game window with a custom underlay.

Parameters:

  • underlay_draw function A draw callback rendered after the background but before overlays.
GameWindow.update ()
Updates the game window logic.
GameWindow.set_state (new_state)
Sets the active window.

Parameters:

  • new_state string The ID of the new active window.

Main

TIC ()
Main game loop (TIC-80 callback).
generated by LDoc 1.5.0 Last updated 2026-08-06 08:24:51