Advertisement
AdamMathieson

cc_main_display_1

Aug 6th, 2022
1,023
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.49 KB | None | 0 0
  1. local basalt = require("Basalt") --> Load the Basalt framework
  2.  
  3. --> Create the first frame. Please note that Basalt needs at least one active "non-parent" frame to properly supply events
  4. --> When Basalt#createFrame makes use of unique identifiers (commonly referred to as UIDs), meaning that the supplied value must be UNIQUE
  5. --> If the supplied UID is ambiguous, Basalt#createFrame returns a nil value
  6. local mainFrame = basalt.createFrame("mainFrame")
  7.  
  8. --> Show the frame to the user
  9. mainFrame:show()
  10.  
  11. local button = mainFrame:addButton("clickableButton") --> Add a button to the mainFrame (With a unique identifier)
  12.  
  13. --> Set the position of the button, Button#setPosition follows an x, y pattern.
  14. --> The x value is how far right the object should be from its anchor (negative values from an anchor will travel left)
  15. --> The y value is how far down the object should be from its anchor (negative values from an anchor will travel up)
  16. button:setPosition(4, 4)
  17.  
  18. button:setText("Click me!") --> Set the text of our button
  19.  
  20. local function buttonClick() --> This function serves as our click logic
  21.     basalt.debug("I got clicked!")
  22. end
  23.  
  24. --> Remember! You cannot supply buttonClick(), that will only supply the result of the function
  25. --> Make sure the button knows which function to call when it's clicked
  26. button:onClick(buttonClick)
  27.  
  28. button:show() --> Make the button visible, so the user can click it
  29.  
  30. basalt.autoUpdate() --> Basalt#autoUpdate starts the event listener to detect user input
  31.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement