Razara

portalDoors

May 15th, 2013
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.61 KB | None | 0 0
  1. local choices = {
  2. {"Farm",false,colors.orange},
  3. {"Walrus",false,colors.green}
  4. {"Bees",false,colors.red}
  5. }
  6.  
  7.  
  8. local choice = 0
  9. local base = {true, colors.white}
  10. local size = #choices;
  11.  
  12. function update()
  13. mon.setCursorPos(1,1)
  14. mon.setBackgroundColor(colors.black)
  15. mon.clear()
  16.  
  17. for i=1,size do
  18.         if choices[i][2] then
  19.                 mon.setTextColor(colors.green)
  20.         else
  21.                 mon.setTextColor(colors.red)
  22.         end
  23.         mon.setCursorPos(1,i)
  24.         mon.write(choices[i][1])      
  25. end
  26.  
  27. signal()
  28. end
  29.  
  30.  
  31. function signal()
  32. local output = 0
  33.  
  34. for i=1,size do
  35.         if choices[i][2] then
  36.           output = choices[i][3]
  37.         end
  38. end
  39. if choice == 0 then
  40.     redstone.setBundledOutput("right",0)
  41. else
  42.     redstone.setBundledOutput("right",colors.white + output)
  43. end
  44. end
  45.  
  46.  
  47. mon = peripheral.wrap("back")
  48. update()
  49.  
  50.  
  51. while true do
  52.         event, p1, x, y= os.pullEvent()
  53.        
  54.         if event == "monitor_touch" then
  55.                 if y <= size then
  56.                         for i = 1,size do
  57.                                 choices[i][2] = false
  58.                         end
  59.                    
  60.                         choices[y][2] = true
  61.                         choice = choices[y][3]
  62.                         update()
  63.                 end
  64.         elseif event == "redstone" then
  65.                 if rs.getBundledInput("right") == colors.white+colors.black+choice then
  66.              for i = 1,size do
  67.                                 choices[i][2] = false
  68.                         end
  69.             choice = 0
  70.             update()
  71.                 end            
  72.         end
  73. end
Advertisement
Add Comment
Please, Sign In to add comment