Advertisement
LTNightshade

Elevator_L1

Feb 8th, 2013
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.93 KB | None | 0 0
  1. -- Elevator Level 1
  2.  
  3.  
  4. -- Front        : Door
  5. -- bottom       : Button
  6.  
  7. function ReadNet()
  8.     print ("Running in RedNet")
  9.     while true do
  10.         event, id, text = os.pullEvent()
  11.         if event == "rednet_message" then
  12.             if text=="OpenDoor" then
  13.                 print("Opening door")
  14.                 redstone.setOutput("front",false)
  15.             end
  16.             if text=="CloseDoor" then
  17.                 print("closing Door")
  18.                 redstone.setOutput("front",true)
  19.             end
  20.         end
  21.     end    
  22. end
  23.  
  24. function Work()
  25.     print("Running in Work")
  26.     while true do
  27.         local event = os.pullEvent()
  28.         if (redstone.getInput("bottom")) then
  29.             print("Button Level 1 pressed")
  30.             rednet.broadcast("L1ButtonPressed")
  31.         end
  32.     end
  33. end
  34.  
  35. function main()
  36.     print("Startup...")
  37.     rednet.open("left")
  38.     parallel.waitForAny(ReadNet, Work)
  39. end
  40.  
  41. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement