Hoodai

Turtle refuel off lava (fluid transposer required)

Feb 25th, 2014
1,117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.42 KB | None | 0 0
  1. -- Setup:
  2. --
  3. -- (1) - Place a fluid transposer with power and a lava
  4. -- source (pipe) attached to it. These can be on any side
  5. -- except the top and the side you want the turtle to put
  6. -- the bucket in.
  7. --
  8. -- (2) - Place the turtle on top of the fluid transposer.
  9. -- Open the transposer interface and make sure the lava
  10. -- source's side is blue, the top side is orange, and
  11. -- the side that the turtle has its back to is blue.
  12. -- If the side the turtle has its back to is the front of
  13. -- the transposer, the transposer must be turned.
  14. --
  15. -- (3) - Lastly, put a bucket in the transposer and run
  16. -- the program.
  17.  
  18. -- Additional Options:
  19. --
  20. --  Arguments:
  21. --      The first argument in the program is an option to make
  22. --      turtle refuel to that fuel level instead of the default
  23. --      1,000,000 fuel.
  24. --
  25. --  Pausing:
  26. --      You can pause the turtle with a redstone signal to the
  27. --      front of the turtle while it is above the transposer
  28. --      example:         /      \       \
  29. --                      []T     []T     []  = lever
  30. --                      --F     --F     T   = turtle
  31. --                                      --  = pipe
  32. --                                      F   = fluid transposer
  33.  
  34. openSlot = 1
  35.  
  36. args = { ... }
  37. if table.getn(args) < 1 then
  38.     fullyFueled = 1000000
  39. else
  40.     fullyFueled = tonumber(args[1])
  41. end
  42.  
  43. function saveFirstOpenSlot()
  44.     for i=1,16 do
  45.         if turtle.getItemCount(i) == 0 then
  46.             openSlot = i
  47.             break
  48.         end
  49.     end
  50. end
  51.  
  52. function refuel()
  53.     shell.run("refuel","all")
  54.     turtle.select(openSlot)
  55.     while not turtle.back() do
  56.     end
  57.     while not turtle.down() do
  58.     end
  59.     turtle.drop()
  60.     while not turtle.up() do
  61.     end
  62.     saveFirstOpenSlot()
  63.     while not turtle.forward() do
  64.     end
  65.     term.clear()
  66.     term.setCursorPos(1,1)
  67.     print("Waiting for bucket --> Is the transposer out of lava?")
  68.     event = os.pullEvent("turtle_inventory")
  69. end
  70.  
  71. term.clear()
  72. term.setCursorPos(1,1)
  73. print("Starting program...")
  74. while turtle.getFuelLevel() < fullyFueled do
  75.     -- will stop refueling while on top of the fluid transposer
  76.     -- if a redstone signal is applied to the front of the turtle
  77.     -- until the redstone signal is removed (flipped off) the
  78.     -- turtle waits
  79.     while (not redstone.getInput("front")) and (turtle.getFuelLevel() < fullyFueled) do
  80.         term.clear()
  81.         term.setCursorPos(1,1)
  82.         print("No Redstone Signal --> Fueling")
  83.         refuel()
  84.     end
  85.     term.clear()
  86.     term.setCursorPos(1,1)
  87.     print("Redstone Signal Detected --> Pausing")
  88.     event = os.pullEvent("redstone")
  89. end
  90. term.clear()
  91. term.setCursorPos(1,1)
  92. print("Fuel Level: "..turtle.getFuelLevel())
Advertisement
Add Comment
Please, Sign In to add comment