Frequently Asked Questions
General
What is Basalt?
Basalt is a UI framework for CC:Tweaked that helps you create user interfaces easily and efficiently. It provides pre-built components, event handling, and advanced features like animations and themes.
Why should I use Basalt instead of direct terminal manipulation?
Basalt handles many complex aspects automatically:
- Event management
- Screen rendering
- Component positioning
- State management
- Layout organization
Installation
How do I install Basalt?
lua
wget run https://raw.githubusercontent.com/Pyroxenium/Basalt2/main/install.lua
wget run https://raw.githubusercontent.com/Pyroxenium/Basalt2/main/install.lua
Can I customize my installation?
Yes! The installer allows you to:
- Choose between Release/Dev versions
- Select specific components
- Include LuaLS definitions
- Enable minification
Common Issues
Why isn't my UI updating?
Remember to call basalt.run()
at the end of your program. Without it, your UI won't start.
Why are my elements not visible?
Check:
- Element positions are within parent bounds
- Parent container is large enough
- Element's
visible
property is true - Z-index conflicts with other elements
How do I handle screen resizes?
Use dynamic positioning with strings, or use functions:
lua
element:setPosition("{parent.width - 5}", 5) -- 5 from right edge
element:setSize("{parent.width - 10}", 5) -- 5 padding on each side
element:setPosition(function(self) -- Another example, but as function call
return self:getParent() - 5
end, 5)
element:setPosition("{parent.width - 5}", 5) -- 5 from right edge
element:setSize("{parent.width - 10}", 5) -- 5 padding on each side
element:setPosition(function(self) -- Another example, but as function call
return self:getParent() - 5
end, 5)
Development
How do I add custom plugins?
Create a new plugin in the plugins directory. See pluginExample for a example on how to create plugins
Where can I find more examples?
How do I contribute?
- Fork the repository
- Create a feature branch
- Submit a pull request
- Join our Discord for discussion
Performance
How can I optimize my Basalt application?
Basalt does already a lot of optimization:
- The render loop only runs when something visually changed (color, position, size,..) which means it only runs once, even if Basalt gets spammed with events (timer events or mouse events).
- The event system is highly optimized:
- Events are only registered for elements that actually use them
- Events bubble up through the element hierarchy efficiently
- Event handlers are stored in a flat structure for quick access
- Events are automatically cleaned up when elements are removed
- Parent containers only receive events their children actually use
Additional tips for optimization:
- Group elements in Frames to reduce render calls
- Use
setVisible(false)
instead of removing elements you'll need again - In case you need a LOT of elements you can use addDelayed{Element}, for example addDelayedButton instead of addButton