LordLoki

While true do

May 7th, 2013
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.64 KB | None | 0 0
  1. side = "back"
  2. m = peripheral.wrap(side)
  3. m.setTextColor(colors.white)
  4. on = false
  5. rednet.open("right")
  6. open = false
  7. m.clear()
  8. m.setTextScale(2)
  9.  
  10. function set_screen()
  11. if on and open  then
  12.     m.setCursorPos(1,4)
  13.     m.clearLine()
  14.     m.write(" [On]   [Open]")
  15. elseif on and not open then
  16.     m.setCursorPos(1,4)
  17.     m.clearLine()
  18.     m.write(" [On]   [Close]")
  19. elseif not on and not open then
  20.     m.setCursorPos(1,4)
  21.     m.clearLine()
  22.     m.write(" [Off]  [Close]")
  23. elseif  not on and open then
  24.     m.setCursorPos(1,4)
  25.     m.clearLine()
  26.     m.write(" [Off]  [Open]")
  27. else
  28.     m.setCursorPos(1,4)
  29.     m.clearLine()
  30.     m.write("Unexpected State Combination")
  31. end
  32. m.setCursorPos(10,4)
  33. m.write(xp_levels)
  34. end
  35.  
  36. function set_rs()
  37. if on and open  then
  38.     rs.setBundledOutput("bottom",colors.red)
  39. elseif on and not open then
  40.     rs.setBundledOutput("bottom",colors.combine(colors.lime,colors.red))
  41. elseif not on and not open then
  42.     rs.setBundledOutput("bottom",colors.lime)
  43. elseif not on and open  then
  44.     rs.setBundledOutput("bottom",colors.cyan)
  45. end
  46. end
  47.  
  48. function set_states(arg1, arg2, arg3)
  49. if (arg2>=2) and (arg2<=4) and (arg3==4) then
  50.     on = not on
  51. elseif (arg2>=15) and (arg2<=23) and (arg3==4) then
  52.     if on then
  53.         open = false
  54.     else
  55.         open = true
  56.     end
  57. end
  58. end
  59.  
  60.  
  61. --{base of program
  62. m.setCursorPos(1,1)
  63. m.write("    -=[Spawning]=- ")
  64. m.setCursorPos(1,3)
  65. m.write(" Spawner XP Hactches")
  66.  
  67. while true do
  68. event, arg1, arg2, arg3 = os.pullEvent()
  69.     if event == "rednet_message" then
  70.         xp_levels = arg2 -- the message is arg2
  71.     elseif event == "monitor_touch" then
  72.         set_states(arg1, arg2, arg3) -- send the side, x, and y to the function
  73.     end
  74. set_screen()
  75. set_rs()
  76. end
Advertisement
Add Comment
Please, Sign In to add comment