Advertisement
Snowdingerr

CCTweaked: Refill with lava in nether

Feb 15th, 2025
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.63 KB | Source Code | 0 0
  1. local cx = 0
  2. local cy = 0
  3. local cz = 0
  4. local objective = turtle.getFuelLimit()
  5.  
  6. objective = objective - 300
  7.  
  8. function clearConsole()
  9.     term.clear()
  10.     term.setCursorPos(1,1)
  11. end
  12.  
  13. function fillAndDrink()
  14.     turtle.placeDown()
  15.     if turtle.getItemCount(1) == 0 then
  16.         return false
  17.     end
  18.     turtle.select(1)
  19.     turtle.refuel()
  20.     clearConsole()
  21.     print("----------")
  22.     print("fuel: " .. turtle.getFuelLevel() .. "/" .. objective)
  23.     print("----------")
  24.     return true
  25. end
  26.  
  27. function isDrinkable()
  28.     local success, data = turtle.inspectDown()
  29.     return not success or data.name == "minecraft:lava"
  30. end
  31.  
  32. function findFloor()
  33.     local originalY = cy
  34.     while isDrinkable() and turtle.getFuelLevel() < objective do
  35.         turtle.down()
  36.         cy = cy - 1
  37.         fillAndDrink()
  38.     end
  39.  
  40.     while cy < originalY do
  41.         turtle.up()
  42.         cy = cy + 1
  43.     end
  44.     return turtle.getFuelLevel() >= objective
  45. end
  46.  
  47. function line()
  48.     local originalX = cx
  49.     while cx < 50 and turtle.getFuelLevel() < objective do
  50.         turtle.forward()
  51.         cx = cx + 1
  52.         if findFloor() then
  53.             break
  54.         end
  55.     end
  56.  
  57.     while cx > originalX do
  58.         turtle.back()
  59.         cx = cx - 1
  60.     end
  61. end
  62.  
  63. function goBackToSpawn()
  64.     while cx > 0 do
  65.         turtle.back()
  66.         cx = cx - 1
  67.     end
  68.     while cy > 0 do
  69.         turtle.up()
  70.         cy = cy + 1
  71.     end
  72.     while cz > 0 do
  73.         turtle.back()
  74.         cz = cz - 1
  75.     end
  76. end
  77.  
  78. while turtle.getFuelLevel() < objective do
  79.     line()
  80.     if cx > 25 then
  81.         break
  82.     end
  83. end
  84. goBackToSpawn()
  85.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement