Slaide

Untitled

Mar 31st, 2023
16
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. monitor = peripheral.find("monitor")
  2. width, height = monitor.getSize()
  3. title = "Ore Processing"
  4.  
  5. buttons = {}
  6.  
  7. function createButton(name, func, x, y, w, h)
  8. nameLen = string.len(name)
  9. buttons[name] = { name, func, x, y, w, h, nameLen }
  10. monitor.setBackgroundColor(colors.red)
  11. for i = y, y + h do
  12. monitor.setCursorPos(x, i)
  13. for j = 1, w do
  14. monitor.write(" ")
  15. end
  16. end
  17. monitor.setCursorPos((x + x + w) / 2 - nameLen / 2, (y + y + h) / 2)
  18. monitor.write(name)
  19.  
  20. --monitor.setCursorPos(5, 3)
  21. --monitor.write()
  22. end
  23.  
  24. function draw()
  25. monitor.setBackgroundColor(colors.black)
  26. monitor.clear()
  27. monitor.setCursorPos(width / 2 - 7, 1)
  28. monitor.write(title)
  29.  
  30. createButton("Test Button", test1, 5, 3, 13, 3)
  31. end
  32.  
  33. while true do
  34. draw()
  35. os.sleep(0.5)
  36. end
  37.  
Advertisement
Add Comment
Please, Sign In to add comment