mercwear

user_interface

May 2nd, 2025 (edited)
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.19 KB | None | 0 0
  1. --This script expects the basalt lib directory to be one directory above it (it should live in the startup directory in the root of the computer)
  2. local basalt = require("/basalt") --UI Library for cc tweaked
  3.  
  4. -- Get a reference to the monitor
  5. local monitor = peripheral.find("monitor")
  6. -- Or specific side: peripheral.wrap("right")
  7.  
  8. -- Create frame for monitor
  9. local monitorFrame = basalt.createFrame():setTerm(monitor) -- :setTerm is the important method here
  10.  
  11. local function get_light_status()
  12. if redstone.getOutput("bottom") == true then
  13. light_status = "On"
  14. bg_color = colors.green
  15. else
  16. light_status = "Off"
  17. bg_color = colors.gray
  18. end
  19.  
  20. end
  21.  
  22. get_light_status()
  23. -- Add elements like normal
  24. my_button = monitorFrame:addButton()
  25. :setText(light_status)
  26. :setWidth(24)
  27. :setPosition(2, 2)
  28. :setBackground(bg_color)
  29. :onClick(function()
  30. -- Toggle redstone output on bottom of computer when clicked
  31. redstone.setOutput("bottom", not redstone.getOutput("bottom"))
  32. get_light_status()
  33. my_button:setBackground(bg_color)
  34. my_button:setText(light_status)
  35.  
  36. end)
  37.  
  38. -- Start Basalt
  39. basalt.run()
Advertisement
Add Comment
Please, Sign In to add comment