basalt
Fields
| Field | Type | Description |
|---|---|---|
| VERSION | string | Current Basalt version |
| traceback | boolean | Whether error screens include the Lua traceback |
| errors | table | Error parsing and display utilities |
| rgb | fun(value: string|number, g?: number, b?: number): number | RGB color helper |
| state | fun(initialValue: any): Signal | Creates writable reactive state |
| signal | fun(initialValue: any): Signal | Alias for state |
| computed | fun(fn: fun(): any): Computed | Creates a computed reactive value |
| isState | fun(value: any): boolean | Tests whether a value is reactive state |
| auto | fun(): LayoutValue | Creates an intrinsic-size layout value |
| fill | fun(weight?: number): LayoutValue | Creates a weighted fill layout value |
| percent | fun(amount: number): LayoutValue | Creates 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 namereturns api (
table) The module's API table
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 peripheralreturns 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 runreturns co (
thread) The coroutine handle
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.