DorianH935

Untitled

Jul 18th, 2024
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. local obsidianOS = require("obsidianOS")
  2.  
  3. -- Example createButton and drawButton
  4. local button1 = obsidianOS.createButton(10, 10, 30, 15, "Button 1", colors.green, colors.black, colors.white, colors.green, function()
  5. print("Button 1 clicked!")
  6. end)
  7.  
  8. local button2 = obsidianOS.createButton(40, 10, 60, 15, "Button 2", colors.blue, colors.black, colors.white, colors.blue, function()
  9. print("Button 2 clicked!")
  10. end)
  11.  
  12. local monitor = peripheral.find("monitor") -- Find a connected monitor
  13.  
  14. obsidianOS.drawButton(button1, monitor)
  15. obsidianOS.drawButton(button2, monitor)
  16.  
  17. -- Example to test button click detection
  18. while true do
  19. local event, side, x, y = os.pullEvent("monitor_touch")
  20. if obsidianOS.handleButtonClick({button1, button2}, x, y, monitor) then
  21. -- Button click detected
  22. -- Do nothing here, the function call prints the message directly
  23. else
  24. print("No button clicked.")
  25. end
  26. end
  27.  
Advertisement
Add Comment
Please, Sign In to add comment