Razara

spawner

Feb 24th, 2013
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.97 KB | None | 0 0
  1. local choices = {
  2. {" Chickens",false,colors.gray},
  3. {" Blazes",false,colors.yellow},
  4. {" Endermen",false,colors.black},
  5. {" Spiders",false,colors.brown},
  6. {" Creepers",false,colors.green}
  7. }
  8.  
  9. local door = {true, colors.white}
  10. local size = #choices;
  11. local totalColor = 0
  12.  
  13. for i=1,size do
  14.   totalColor = totalColor + choices[i][3]
  15. end
  16.  
  17. function update()
  18. cx,cy = term.getCursorPos()
  19. term.clear()
  20. term.setCursorPos(1,1)
  21. for i=1,size do
  22.     if choices[i][2] then
  23.         term.setTextColor(colors.green)
  24.     else
  25.         term.setTextColor(colors.red)
  26.     end
  27.     print(choices[i][1])
  28. end
  29.  
  30. term.setCursorPos(1,size+2)
  31. term.setTextColor(colors.white)
  32.  
  33. if door[1] then
  34.     term.setTextColor(colors.green)
  35. else
  36.     term.setTextColor(colors.red)
  37. end
  38. print(" Door")
  39.  
  40. term.setCursorPos(1,18)
  41. term.setTextColor(colors.white)
  42. write("Up/Down to select, Enter to toggle")
  43. term.setCursorPos(cx,cy)
  44.  
  45. signal()
  46. end
  47.  
  48.  
  49. function signal()
  50. local output = 0
  51. if door[1] then
  52.  output = door[2]
  53. else
  54.  for i=1,size do
  55.     if choices[i][2] then
  56.       output = output-choices[i][3]
  57.     end
  58.  end
  59. end
  60. redstone.setBundledOutput("back",totalColor + output)
  61. end
  62.  
  63.  
  64. term.setCursorBlink(true)
  65. term.setCursorPos(1,1)
  66. update()
  67.  
  68. while true do
  69.     event, p1 = os.pullEvent()
  70.     x,y = term.getCursorPos()
  71.    
  72.     if event == "key" then
  73.         if p1 == 28 then-- enter
  74.             if y <= size then
  75.                 for i = 1,size do
  76.                 if i ~= y then
  77.                  choices[i][2] = false
  78.                  end
  79.                 end
  80.                 choices[y][2] = not choices[y][2]
  81.                
  82.                 if choices[y][2] then
  83.                     door[1] = false
  84.                 end
  85.             elseif y == size+2 then
  86.                 door[1] = not door[1]
  87.                 if door[1] then
  88.                     for i = 1,size do
  89.                         choices[i][2] = false
  90.                     end
  91.                 end
  92.             end
  93.             update()
  94.         elseif p1 == 200 then-- up
  95.             if y - 1  >= 1 then
  96.                 term.setCursorPos(x,y-1)
  97.             end
  98.         elseif p1 == 208 then-- down
  99.             if y + 1 <= size+2 then
  100.                 term.setCursorPos(x,y+1)
  101.             end
  102.         end
  103.    
  104.     end
  105. end
  106. -- up 200
  107. -- down 208
  108. -- enter 28
  109.  
  110.  
  111. --spider
  112. --chicken
  113. --blaze
  114. --endermen
Advertisement
Add Comment
Please, Sign In to add comment