Advertisement
Swimy

TileLayer

Feb 4th, 2018
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.74 KB | None | 0 0
  1. local fuelSlot = 1
  2.  
  3. turtle.select(2)  --start on first slot
  4. local stackCount = turtle.getItemCount()
  5.  
  6. function updateStackCount()
  7.   stackCount = turtle.getItemCount(turtle.getSelectedSlot())
  8. end
  9.  
  10. function swapSelected()
  11.   updateStackCount()
  12.   if stackCount==0 then
  13.     currSlot = turtle.getSelectedSlot()
  14.     currSlot = currSlot + 1
  15.     turtle.select(currSlot)
  16.   end
  17. end
  18.  
  19. function checkFuel()
  20.   if turtle.getFuelLevel() <= 1 then
  21.     prevSelected = turtle.getSelectedSlot()
  22.     turtle.select(fuelSlot) --fuel goes in this slot
  23.     turtle.refuel(1)
  24.     turtle.select(prevSelected) --use any slot here, I default to 1, depending on the program.
  25.   end
  26. end
  27.  
  28. while turtle.back() do
  29.   checkFuel()
  30.   swapSelected()
  31.   turtle.place()
  32. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement