KedrikFeeD

basalt-usage-example

Feb 8th, 2025
9
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.98 KB | None | 0 0
  1. local basalt = require("basalt") --> Load the Basalt framework into the variable called "basalt"
  2.  
  3. --> Now we want to create a base frame, we call the variable "main" - by default everything you create is visible. (you don't need to use :show())
  4. local main = basalt.createFrame()
  5.  
  6. local button = main:addButton() --> Here we add our first button
  7. button:setPosition(4, 4) -- We want to change the default position of our button
  8. button:setSize(16, 3) -- And the default size.
  9. button:setText("Click me!") --> This method sets the text displayed on our button
  10.  
  11. local function buttonClick() --> Create a function we want to call when the button gets clicked
  12.     basalt.debug("I got clicked!")
  13. end
  14.  
  15. -- Now we just need to register the function to the button's onClick event handlers, this is how we can achieve that:
  16. button:onClick(buttonClick)
  17.  
  18. basalt.autoUpdate() -- As soon as we call basalt.autoUpdate, the event and draw handlers will listen to any incoming events (and draw if necessary)
  19.  
Add Comment
Please, Sign In to add comment