DrFair

Mob Farms

Apr 1st, 2013
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.68 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. active = 65535
  7. redstone.setBundledOutput("right",active)
  8.  
  9. function toggle(color,bool)
  10. if bool then
  11. active = active + col[color]
  12. else
  13. active = active - col[color]
  14. end
  15. redstone.setBundledOutput("right",active)
  16. print(active)
  17. end
  18.  
  19. function swrite(str,x,y,color)
  20. m.setCursorPos(x,y)
  21. m.setTextColor(col[color])
  22. m.write(str)
  23. end
  24.  
  25. function swritecenter(str,y,color)
  26. m.setCursorPos((w/2-#str/2)+1,y)
  27. m.setTextColor(col[color])
  28. m.write(str)
  29. end
  30.  
  31. function drawbox(str,x1,x2,y1,y2,strcol,color)
  32. m.setCursorPos(x1,y1)
  33. m.setBackgroundColor(col[color])
  34. m.setTextColor(col[strcol])
  35. local bw = x2-x1
  36. local bh = y2-y1
  37. local bstr = " "
  38. while #bstr < bw do
  39. bstr = bstr.." "
  40. end
  41. for i=1,bh do
  42. m.setCursorPos(x1,y1+i-1)
  43. m.write(bstr)
  44. end
  45. m.setCursorPos(x1+bw/2-#str/2,y1+bh/2)
  46. m.write(str)
  47. m.setBackgroundColor(col["black"])
  48. return { [1]=x1, [2]=x2, [3]=y1, [4]=y2 }
  49. end
  50.  
  51. function drawtext(str,x,y,color)
  52. m.setCursorPos(x,y)
  53. m.setTextColor(col[color])
  54. m.write(str)
  55. return { [1]=x, [2]=x+1, [3]=y, [4]=y+#str }
  56. end
  57.  
  58. function press(but)
  59. if event == "monitor_touch" then
  60. if pr2 >= but[1] and pr2 < but[2] and pr3 >= but[3] and pr3 < but[4] then
  61. return true
  62. else
  63. return false
  64. end
  65. end
  66. end
  67.  
  68. function drawoutline(str,strcol,color)
  69. m.setBackgroundColor(col[color])
  70. m.setTextColor(col[strcol])
  71. drawbox(str,1,w,1,2,strcol,color)
  72. drawbox("",1,2,1,h,strcol,color)
  73. drawbox("",w-1,w,1,h,strcol,color)
  74. drawbox("",1,w,h-1,h,strcol,color)
  75. end
  76.  
  77. function check(color)
  78. return colors.test(active,col[color])
  79. end
  80.  
  81. function drawmenu()
  82. m.clear()
  83. drawoutline("Fair's Mobfarm system","black","white")
  84. enderman = drawbox("Enderman",4,19,3,6,"black","red")
  85. blaze = drawbox("Blaze",22,37,3,6,"black","red")
  86. zombie = drawbox("Zombie",4,19,7,10,"black","red")
  87. spider = drawbox("Spider",22,37,7,10,"black","red")
  88. creeper = drawbox("Creeper",4,19,11,14,"black","red")
  89. na = drawbox("N/A",22,37,11,14,"black","red")
  90. na = drawbox("N/A",4,19,15,18,"black","red")
  91. na = drawbox("N/A",22,37,15,18,"black","red")
  92. na = drawbox("N/A",4,19,19,22,"black","red")
  93. na = drawbox("N/A",22,37,19,22,"black","red")
  94. end
  95.  
  96. drawmenu()
  97.  
  98. while true do
  99. event,pr1,pr2,pr3 = os.pullEvent()
  100. if press(enderman) then
  101. if check("white") then
  102. toggle("white",false)
  103. enderman = drawbox("Enderman",4,19,3,6,"black","green")
  104. else
  105. toggle("white",true)
  106. enderman = drawbox("Enderman",4,19,3,6,"black","red")
  107. end
  108. elseif press(blaze) then
  109. if check("orange") then
  110. toggle("orange",false)
  111. blaze = drawbox("Blaze",22,37,3,6,"black","green")
  112. else
  113. toggle("orange",true)
  114. blaze = drawbox("Blaze",22,37,3,6,"black","red")
  115. end
  116. elseif press(zombie) then
  117. if check("yellow") then
  118. toggle("yellow",false)
  119. zombie = drawbox("Zombie",4,19,7,10,"black","green")
  120. else
  121. toggle("yellow",true)
  122. zombie = drawbox("Zombie",4,19,7,10,"black","red")
  123. end
  124. elseif press(spider) then
  125. if check("red") then
  126. toggle("red",false)
  127. spider = drawbox("Spider",22,37,7,10,"black","green")
  128. else
  129. toggle("red",true)
  130. spider = drawbox("Spider",22,37,7,10,"black","red")
  131. end
  132. elseif press(creeper) then
  133. if check("black") then
  134. toggle("black",false)
  135. creeper = drawbox("Creeper",4,19,11,14,"black","green")
  136. else
  137. toggle("black",true)
  138. creeper = drawbox("Creeper",4,19,11,14,"black","red")
  139. end
  140. end
  141. end
Advertisement
Add Comment
Please, Sign In to add comment