Advertisement
QQII

Multifloor Listener V0.1

Jun 6th, 2013
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.90 KB | None | 0 0
  1. --Multifloor Listener V0.1 by QQII
  2. --Declerations
  3. local Arguments = { ... }           --Program arguments
  4. local currentFloor = tonumber(Arguments[1])
  5. local modem = peripheral.wrap("right")      --Wraps the modem on the right side.
  6. local block = 0                 --Slot that contains a block
  7.  
  8. --Initial
  9. if currentFloor == null then
  10.     print("ERROR: currentFloor = null")
  11.     return
  12. end
  13.  
  14. if (not modem) or (peripheral.getType("right") ~= "modem") then
  15.     print("ERROR: no wireless modem found")
  16.     return
  17. end
  18.  
  19. for i = 1,16 do
  20.     if turtle.getItemCount(i) ~= 0 then
  21.         block = i
  22.     end
  23. end
  24. if block == 0 then
  25.     print("ERROR: no blocks found")
  26.     return
  27. else
  28.     turtle.select(block)
  29. end
  30. modem.open(1000)
  31.  
  32. --Main Loop
  33. while true do
  34.     local event, modemSide, senderChannel, replyChannel, message, senderDistance = os.pullEvent("modem_message")
  35.     if message == currentFloor then
  36.         turtle.place()
  37.         os.sleep(10)
  38.         turtle.dig()
  39.     end
  40. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement