Advertisement
Alakazard12

Spawner

Mar 11th, 2017
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.97 KB | None | 0 0
  1. local monitor = peripheral.find("monitor")
  2. local rside = "back"
  3.  
  4. if not monitor then
  5.     printError("No monitor connected")
  6. end
  7.  
  8. monitor.setTextScale(0.5)
  9. local w, h = monitor.getSize()
  10.  
  11. local function centerPrint(text, y)
  12.     monitor.setCursorPos((w - #text) / 2 + 1, y)
  13.     monitor.write(text)
  14. end
  15.  
  16. local atPos = math.floor(h / 2)
  17. local itPos = math.floor(h / 2) + 1
  18.  
  19. function setActive(active)
  20.     redstone.setOutput(rside, not active)
  21.  
  22.     monitor.setTextColor(colors.white)
  23.     if active then
  24.         monitor.setBackgroundColor(colors.green)
  25.         monitor.clear()
  26.         centerPrint("Active", atPos)
  27.     else
  28.         monitor.setBackgroundColor(colors.red)
  29.         monitor.clear()
  30.         centerPrint("Inactive", atPos)
  31.     end
  32.  
  33.     monitor.setTextColor(colors.lightGray)
  34.     centerPrint("Right click", itPos)
  35.     centerPrint("to toggle", itPos + 1)
  36. end
  37.  
  38. local active = false
  39.  
  40. setActive(active)
  41. while true do
  42.     local event, side, x, y = os.pullEvent("monitor_touch")
  43.  
  44.     active = not active
  45.     setActive(active)
  46. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement