warfar

Logistics Pipe Hopper

Dec 19th, 2014
199
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.38 KB | None | 0 0
  1. local tArgs = { ... }
  2. if #tArgs ~= 2 then
  3.     print("Invalid Arguments: " .. shell.getRunningProgram() .. " <side> <drop/suck>")
  4.     return
  5. end
  6. local side = tArgs[1]
  7. local action = tArgs[2]
  8. if side == "bottom" then
  9.     side = "down"
  10. elseif side == "top" then
  11.     side = "up"
  12. end
  13. if side ~= "up" and side ~= "down" and side ~= "front" then
  14.     print("Invalid Side: up/top,down/bottom,front")
  15.     return
  16. end
  17. if action ~= "drop" and action ~= "suck" then
  18.     print("Invalid Action: suck,drop")
  19.     return
  20. end
  21. for i, v in ipairs(rs.getSides()) do
  22.     if peripheral.getType(v) == "LogisticsPipes:Crafting" then
  23.         peripheral.wrap(v).setTurtleConnect(true)
  24.     end
  25. end
  26. s = fs.open("startup","w")
  27. s.writeLine("shell.run(\""..shell.getRunningProgram().."\",\""..side.."\",\""..action.."\")")
  28. s.close()
  29. while true do
  30.     for i=1,16 do
  31.         turtle.select(i)
  32.         if side == "up" then
  33.             if action == "suck" then
  34.                 turtle.suckUp()
  35.             else
  36.                 turtle.dropUp()
  37.             end
  38.         elseif side == "down" then
  39.             if action == "suck" then
  40.                 turtle.suckDown()
  41.             else
  42.                 turtle.dropDown()
  43.             end
  44.         else
  45.             if action == "suck" then
  46.                 turtle.suck()
  47.             else
  48.                 turtle.drop()
  49.             end
  50.         end
  51.     end
  52. end
Advertisement
Add Comment
Please, Sign In to add comment