Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local obsidianOS = require("obsidianOS")
- -- Example createButton and drawButton
- local button1 = obsidianOS.createButton(10, 10, 30, 15, "Button 1", colors.green, colors.black, colors.white, colors.green, function()
- print("Button 1 clicked!")
- end)
- local button2 = obsidianOS.createButton(40, 10, 60, 15, "Button 2", colors.blue, colors.black, colors.white, colors.blue, function()
- print("Button 2 clicked!")
- end)
- local monitor = peripheral.find("monitor") -- Find a connected monitor
- obsidianOS.drawButton(button1, monitor)
- obsidianOS.drawButton(button2, monitor)
- -- Example to test button click detection
- while true do
- local event, side, x, y = os.pullEvent("monitor_touch")
- if obsidianOS.handleButtonClick({button1, button2}, x, y, monitor) then
- -- Button click detected
- -- Do nothing here, the function call prints the message directly
- else
- print("No button clicked.")
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment