DrFair

Blazefarm monitor

Jun 16th, 2013
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.73 KB | None | 0 0
  1. m = peripheral.wrap("top")
  2. w,h = m.getSize()
  3. w = w+1
  4. h = h+1
  5. col = { ["white"]=1, ["orange"]=2, ["magenta"]=4, ["lightblue"]=8, ["yellow"]=16, ["lime"]=32, ["pink"]=64, ["gray"]=128, ["lightgray"]=256, ["cyan"]=512, ["purple"]=1024, ["blue"]=2048, ["brown"]=4096, ["green"]=8192, ["red"]=16384, ["black"]=32768 }
  6. dispenser = false
  7. extractor = false
  8. os.startTimer(1)
  9. cart = 0
  10. rednet.open("right")
  11. rednet.broadcast("dispoff")
  12.  
  13. function swrite(str,x,y,color)
  14. m.setCursorPos(x,y)
  15. m.setTextColor(col[color])
  16. m.write(str)
  17. end
  18.  
  19. function drawbox(str,x1,x2,y1,y2,strcol,color)
  20. m.setCursorPos(x1,y1)
  21. m.setBackgroundColor(col[color])
  22. m.setTextColor(col[strcol])
  23. local bw = x2-x1
  24. local bh = y2-y1
  25. local bstr = " "
  26. while #bstr < bw do
  27. bstr = bstr.." "
  28. end
  29. for i=1,bh do
  30. m.setCursorPos(x1,y1+i-1)
  31. m.write(bstr)
  32. end
  33. m.setCursorPos(x1+bw/2-#str/2,y1+bh/2)
  34. m.write(str)
  35. m.setBackgroundColor(col["black"])
  36. return { [1]=x1, [2]=x2, [3]=y1, [4]=y2 }
  37. end
  38.  
  39. function press(but)
  40. if event == "monitor_touch" then
  41. if pr2 >= but[1] and pr2 < but[2] and pr3 >= but[3] and pr3 < but[4] then
  42. return true
  43. else
  44. return false
  45. end
  46. end
  47. end
  48.  
  49. function drawbackground(str,strcol,color)
  50. drawbox("",1,w,1,h,strcol,color)
  51. drawbox("",2,w-1,2,h-1,"black","black")
  52. drawbox(str,1,w,1,2,strcol,color)
  53. end
  54.  
  55. function drawmenu()
  56. if active then
  57. button = drawbox("Stop",4,w-3,5,8,"black","green")
  58. rednet.broadcast("blazefarmon")
  59. else
  60. button = drawbox("Start",4,w-3,5,8,"black","red")
  61. rednet.broadcast("blazefarmoff")
  62. end
  63. end
  64.  
  65. drawbackground("Blaze XP Farm","black","white")
  66. drawmenu()
  67.  
  68. while true do
  69. event,pr1,pr2,pr3 = os.pullEvent()
  70. if press(button) then
  71. active = not active
  72. drawmenu()
  73. end
  74. end
Advertisement
Add Comment
Please, Sign In to add comment