Advertisement
natie3

FloorSwitcher

Dec 1st, 2019
604
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.56 KB | None | 0 0
  1. modem = peripheral.wrap("left")
  2. modem.open(15)
  3.  
  4. local f = fs.open("loc.lua", "r")
  5. loc = tonumber(f.readLine())
  6. f.close()
  7.  
  8. turtle.select(1)
  9. current = (turtle.getItemCount() > 0 and "2") or "1"
  10.  
  11. function switch(new)
  12.   for i = 1, 4 do
  13.     turtle.select(1)
  14.     turtle.digUp()
  15.     turtle.select(new)
  16.     turtle.placeUp()
  17.     turtle.forward()
  18.     turtle.turnRight()
  19.   end
  20. end  
  21.  
  22. while true do
  23.   e, _, _, _, message = os.pullEvent("modem_message")
  24.   new = message:sub(loc, loc)
  25.   if new ~= current then
  26.     switch(tonumber(new))
  27.     current = new
  28.   end
  29. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement