Advertisement
jared314

Untitled

Jul 31st, 2015
298
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.16 KB | None | 0 0
  1. m = peripheral.wrap("right")
  2. m.clear()
  3. spawner = peripheral.wrap("bottom")
  4.  
  5. onX = 2
  6. onY = 3
  7. offX = 2
  8. offY = 5
  9.  
  10. function draw_buttons(type)
  11. if type == 1 then
  12. draw_text(onX,onY,"On", colors.white, colors.black)
  13. draw_text(offX,offY,"Off", colors.white, colors.black)
  14. else if type == 2 then
  15. draw_text(onX,onY,"On", colors.white, colors.green)
  16. draw_text(offX,offY,"Off", colors.white, colors.black)
  17. else if type == 3 then
  18. draw_text(onX,onY,"On", colors.white, colors.black)
  19. draw_text(offX,offY,"Off", colors.white, colors.red)
  20. end
  21. end
  22. end
  23. end
  24.  
  25. function draw_text(x, y, text, text_color, bg_color)
  26. m.setBackgroundColor(bg_color)
  27. m.setTextColor(text_color)
  28. m.setCursorPos(x,y)
  29. m.write(text)
  30. end
  31.  
  32. function spawnOff()
  33. rs.setOutput("back", true)
  34. end
  35.  
  36. function spawnOff()
  37. rs.setOutput("back", false)
  38. end
  39.  
  40. draw_buttons(1)
  41.  
  42. draw_text(2,1,"Spawner Control", colors.white, colors.black)
  43.  
  44. while true do
  45. event, side, x, y = os.pullEvent("monitor_touch")
  46. if y == onY and x >= onX and x <= onX + 2 then
  47. draw_buttons(2)
  48. spawnOn()
  49. else if y == offY and x >= offX and x <= offX + 3 then
  50. draw_buttons(3)
  51. spawnOff()
  52. end
  53. end
  54. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement