Advertisement
siulsalas

Untitled

Jan 20th, 2020
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. -- https://pastebin.com/D8yWJ7rh
  2. function newManager(side)
  3. local manager = {
  4. buttons = {},
  5. monitor = peripheral.wrap(side),
  6. newButton = function(self, label)
  7. print("creating button ''"..label.."''")
  8. self.buttons[label] = {
  9. label = label,
  10. text = "_ "..label
  11. }
  12. end,
  13. draw = function(self)
  14. print("starting draw()")
  15. self.monitor.clear()
  16. self.monitor.setCursorPos(1,2)
  17. local yPos = 2
  18. for button in self.buttons do
  19. self.monitor.write(button.text)
  20. yPos = yPos + 1
  21. self.monitor.setCursorPos(1,yPos)
  22. end
  23. end
  24. }
  25. return manager
  26. end
  27.  
  28. local mgr = newManager("top")
  29. mgr:newButton("Iron")
  30. mgr:newButton("Dye")
  31. mgr:newButton("Coal")
  32. mgr:draw()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement