4.7 KiB
basalt
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:
Usage
local basalt = require("basalt")
What this code does is it loads basalt into the project, and you can access it by using the variable defined as "basalt".
Fields
| Field | Type | Description |
|---|---|---|
| traceback | boolean |
Whether to show a traceback on errors |
| _events | table |
A table of events and their callbacks |
| _schedule | function[] |
A table of scheduled functions |
| _plugins | table |
A table of plugins |
| isRunning | boolean |
Whether the Basalt runtime is active |
| LOGGER | Log |
The logger instance |
| path | string |
The path to the Basalt library |
Functions
| Method | Returns | Description |
|---|---|---|
| basalt.create | table | Creates a new UI element |
| basalt.createFrame | BaseFrame | Creates a new BaseFrame |
| basalt.getAPI | table | Returns a Plugin API |
| basalt.getActiveFrame | BaseFrame? | Returns the active frame |
| basalt.getElementClass | table | Returns an element class |
| basalt.getElementManager | table | Returns the element manager |
| basalt.getErrorManager | table | Returns the error manager |
| basalt.getFocus | BaseFrame? | Returns the focused frame |
| basalt.getMainFrame | BaseFrame | Gets or creates the main frame |
| basalt.removeSchedule | boolean | Removes a scheduled update |
| basalt.run | - | Starts the Basalt runtime |
| basalt.schedule | thread | Schedules a function to run in a coroutine |
| basalt.setActiveFrame | - | Sets the active frame |
| basalt.setFocus | - | Sets a frame as focused |
| basalt.stop | - | Stops the Basalt runtime |
| basalt.update | - | Runs basalt once |
basalt.create(type, properties?)
Creates and returns a new UI element of the specified type.
Parameters
typestringThe type of element to create (e.g. "Button", "Label", "BaseFrame")properties(optional)string|tableOptional name for the element or a table with properties to initialize the element with
Returns
tableelementThe created element instance
Usage
local button = basalt.create("Button")
basalt.createFrame()
Creates and returns a new BaseFrame
Returns
BaseFrameBaseFrameThe created frame instance
basalt.getAPI(name)
Returns a Plugin API
Parameters
namestringThe name of the plugin
Returns
tablePluginThe plugin API
basalt.getActiveFrame(t?)
Returns the active frame
Parameters
t(optional)termThe term to get the active frame for (default: current term)
Returns
BaseFrame?BaseFrameThe frame to set as active
basalt.getElementClass(name)
Returns an element's class without creating a instance
Parameters
namestringThe name of the element
Returns
tableElementThe element class
basalt.getElementManager()
Returns the element manager instance
Returns
tableElementManagerThe element manager
basalt.getErrorManager()
Returns the error manager instance
Returns
tableErrorManagerThe error manager
basalt.getFocus()
Returns the focused frame
Returns
BaseFrame?BaseFrameThe focused frame
basalt.getMainFrame()
Gets or creates the main frame
Returns
BaseFrameBaseFrameThe main frame instance
basalt.removeSchedule(func)
Removes a scheduled update
Parameters
functhreadThe scheduled function to remove
Returns
booleansuccessWhether the scheduled function was removed
basalt.run(isActive?)
Starts the Basalt runtime
Parameters
isActive(optional)booleanWhether to start active (default: true)
basalt.schedule(func)
Schedules a function to run in a coroutine
Parameters
funcfunctionThe function to schedule
Returns
threadfuncThe scheduled function
basalt.setActiveFrame(frame, setActive?)
Sets the active frame
Parameters
frameBaseFrameThe frame to set as activesetActive(optional)booleanWhether to set the frame as active (default: true)
basalt.setFocus(frame)
Sets a frame as focused
Parameters
frameBaseFrameThe frame to set as focused
basalt.stop()
Stops the Basalt runtime
basalt.update(...)
Runs basalt once, can be used to update the UI manually, but you have to feed it the events
Parameters
...(vararg)anyThe event to run with