Skip to content

basalt

Fields

FieldTypeDescription
VERSIONstringCurrent Basalt version
tracebackbooleanWhether error screens include the Lua traceback
errorstableError parsing and display utilities
rgbfun(value: string|number, g?: number, b?: number): numberRGB color helper
statefun(initialValue: any): SignalCreates writable reactive state
signalfun(initialValue: any): SignalAlias for state
computedfun(fn: fun(): any): ComputedCreates a computed reactive value
isStatefun(value: any): booleanTests whether a value is reactive state
autofun(): LayoutValueCreates an intrinsic-size layout value
fillfun(weight?: number): LayoutValueCreates a weighted fill layout value
percentfun(amount: number): LayoutValueCreates a fractional parent-size value
debug (optional)fun(...: any)Logger installed by basalt.use("debug")

Methods

basalt.use(moduleName)

Loads an optional module from modules/ (e.g. "debug", "animation", "theme", "xml") and returns its API. Modules extend Basalt from the outside; the core has no knowledge of them.

  • moduleName (string) The module name

  • returns api (table) The module's API table

lua
local theme = basalt.use("theme")

basalt.createFrame(t, monitorName)

Creates a root frame bound to a terminal (default: current term). For monitors, pass the wrapped peripheral; touch events are routed automatically. monitorName only needs to be given if auto-detection fails.

  • t (table, optional) The terminal to bind to (default: current term)

  • monitorName (string, optional) The name of the monitor peripheral

  • returns frame (BaseFrame)

basalt.getMainFrame()

Returns the first frame created by basalt.createFrame(), creating one if needed.

  • returns frame (BaseFrame)

basalt.schedule(fn)

Runs a function in a coroutine driven by the event loop; blocking calls like sleep() are allowed inside.

  • fn (function) The function to run

  • returns co (thread) The coroutine handle

lua
basalt.schedule(function() sleep(1) label.text = "later" end)

basalt.update(event, ...)

Feeds a single event through Basalt manually (alternative to run()).

  • event (string) The event name (e.g. "mouse_click", "key", "term_resize")
  • ... (any) Additional event arguments

basalt.stop()

Stops the event loop. Stops the active basalt.run() event loop after the current event.

basalt.run()

Starts the event loop; returns when basalt.stop() is called or on error (after showing the error screen). Runs the blocking event loop until stop() or terminate.

Last updated:

Released under the MIT License.