INCSlayer

portalturtle

Dec 16th, 2012
351
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.82 KB | None | 0 0
  1. -- Define Portal Computer Here (if you do not know what this is use the command: print(os.getComputerID()) on the turtle you will get a number put it after the equal sign below):
  2. pc =
  3.  
  4. function close()
  5.     while true do
  6.         os.pullEvent("redstone")
  7.         if redstone.getInput("bottom") then
  8.             os.sleep(2)
  9.             rednet.send(pc,"close")
  10.             print("close sent")
  11.             turtle.suck()
  12.         end
  13.     end
  14. end
  15.  
  16. function portal()
  17.     id, message = rednet.receive()
  18.     if id == pc and message == "99" then
  19.         print("closing Portal")
  20.         turtle.suck()
  21.         rednet.send(pc,"close")
  22.     elseif id == pc then
  23.     turtle.suck()
  24.     print("opening Portal "..message)
  25.     local message = tonumber(message)
  26.     turtle.select(message)
  27.     turtle.drop()
  28.     end
  29. end
  30.  
  31. turtle.suck()
  32. while redstone.getInput("right") do
  33.     rednet.open("left")
  34.     parallel.waitForAny(portal, close)
  35. end
Advertisement
Add Comment
Please, Sign In to add comment