DMeville

Untitled

Jul 8th, 2013
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. foundMonitor = false
  2. mw, mh = 0
  3. spawners = {}
  4. spawners[0] = false
  5. spawners[1] = true
  6. red = 16384
  7. green = 32
  8. function drawBox(x,y,w,h,c, label)
  9.     i = x
  10.     _w = w + x
  11.     _h = h+y
  12.     while i < _w do
  13.     j = y
  14.         while j < _h do
  15.             paintutils.drawPixel(i,j,c)
  16.             j = j+1
  17.         end
  18.     i = i+1
  19.     end
  20.     mon.setCursorPos(x,y)
  21.     mon.write(label)
  22. end
  23. function drawGUI()
  24.     mon.setCursorPos(1,1)
  25.     if spawners[0] == false then
  26.         drawBox(3,3,10,6, red, "OFF")
  27.     else
  28.         drawBox(3,3,10,6, green, "ON")
  29.     end
  30.  
  31.     if spawners[1] == false then
  32.         drawBox(3,12,10,6, red, "OFF")
  33.     else
  34.         drawBox(3,12,10,6, green, "ON")
  35.     end
  36.  
  37. end
  38. function update()
  39. if spawners[0] == true then spawners[0] = false
  40. else spawners[0] = true
  41. end
  42.  
  43. function init()
  44. if peripheral.isPresent("bottom") then 
  45.     mon = peripheral.wrap("bottom")
  46.     mw, mh = mon.getSize()
  47.     mon.setBackgroundColor(1)
  48.     mon.clear()
  49.     term.redirect(mon)
  50.     foundMonitor = true
  51. else
  52.     foundMonitor = false
  53.     print("Monitor not found - Aborting")
  54. end
  55. if foundMonitor == true then
  56.     while true do
  57.         update()
  58.         drawGUI()
  59.         sleep(1)
  60.     end
  61.     term.restore()
  62. end
  63. end
  64.  
  65. init()
Advertisement
Add Comment
Please, Sign In to add comment