import{_ as a,a as t,b as r,ag as s}from"./chunks/framework.BcrMLAmg.js";const m=JSON.parse('{"title":"basalt","description":"","frontmatter":{},"headers":[],"relativePath":"references/main.md","filePath":"references/main.md","lastUpdated":1757840145000}'),l={name:"references/main.md"};function i(n,e,o,d,h,c){return r(),t("div",null,e[0]||(e[0]=[s('
This is the UI Manager and the starting point for your project. The following functions allow you to influence the default behavior of Basalt.
Before you can access Basalt, you need to add the following code on top of your file:What this code does is it loads basalt into the project, and you can access it by using the variable defined as "basalt".
| Method | Returns | Description |
|---|---|---|
| basalt.create | table | Creates a new UI element |
| basalt.createFrame | BaseFrame | Creates a new BaseFrame |
| basalt.getElementManager | table | Returns the element manager |
| basalt.getErrorManager | table | Returns the error manager |
| basalt.getMainFrame | BaseFrame | Gets or creates the main frame |
| basalt.setActiveFrame | - | Sets the active frame |
| basalt.getActiveFrame | BaseFrame | Returns the active frame |
| basalt.setFocus | - | Sets a frame as focused |
| basalt.getFocus | BaseFrame | Returns the focused frame |
| basalt.schedule | thread | Schedules a function to run in a coroutine |
| basalt.removeSchedule | boolean | Removes a scheduled update |
| basalt.update | - | Runs basalt once |
| basalt.stop | - | Stops the Basalt runtime |
| basalt.run | - | Starts the Basalt runtime |
| basalt.getElementClass | table | Returns an element class |
| basalt.getAPI | table | Returns a Plugin API |
| basalt.onEvent | - | Registers an event callback |
| basalt.removeEvent | boolean | Removes an event callback |
| basalt.triggerEvent | - | Triggers a custom event |
Creates and returns a new UI element of the specified type.
type string The type of element to create (e.g. "Button", "Label", "BaseFrame")properties (optional) string|table Optional name for the element or a table with properties to initialize the element withtable element The created element instancelocal button = basalt.create("Button")Creates and returns a new BaseFrame
BaseFrame BaseFrame The created frame instanceReturns the element manager instance
table ElementManager The element managerReturns the error manager instance
table ErrorManager The error managerGets or creates the main frame
BaseFrame BaseFrame The main frame instanceSets the active frame
frame BaseFrame The frame to set as activesetActive (optional) boolean Whether to set the frame as active (default: true)Returns the active frame
t (optional) term The term to get the active frame for (default: current term)BaseFrame The frame to set as activeSets a frame as focused
frame BaseFrame The frame to set as focusedReturns the focused frame
BaseFrame The focused frameSchedules a function to run in a coroutine
func function The function to schedulethread func The scheduled functionRemoves a scheduled update
func thread The scheduled function to removeboolean success Whether the scheduled function was removedRuns basalt once, can be used to update the UI manually, but you have to feed it the events
Stops the Basalt runtime
Starts the Basalt runtime
isActive (optional) boolean Whether to start active (default: true)Returns an element's class without creating a instance
name string The name of the elementtable Element The element classReturns a Plugin API
name string The name of the plugintable Plugin The plugin APIRegisters a callback function for a specific event
eventName string The name of the event to listen for (e.g. "mouse_click", "key", "timer")callback function The callback function to execute when the event occursbasalt.onEvent("mouse_click", function(button, x, y) basalt.debug("Clicked at", x, y) end)Removes a callback function for a specific event
eventName string The name of the eventcallback function The callback function to removeboolean success Whether the callback was found and removedTriggers a custom event and calls all registered callbacks
eventName string The name of the event to triggerbasalt.triggerEvent("custom_event", "data1", "data2")