Advertisement
Robear9992

refuel

Jul 2nd, 2022 (edited)
486
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. --cc:Tweaked: Turtle Refueler
  2. --pastebin get SB98ccny refuel.lua
  3.  
  4. local inventory = require("inventory")
  5.  
  6. local COAL          = { name = "minecraft:coal" }
  7. local COAL_BLOCK    = { name = "minecraft:coal_block" }
  8. local CHARCOAL      = { name = "minecraft:charcoal" }
  9.  
  10. local FUELS = { COAL, COAL_BLOCK, CHARCOAL }
  11.  
  12. function isFull()
  13.     return turtle.getFuelLevel() == turtle.getFuelLimit()
  14. end
  15.  
  16. for cindex, ifuel in pairs(FUELS) do
  17.     while inventory.findAndSelect(ifuel) == true and not isFull() do
  18.         turtle.refuel()
  19.     end
  20. end
  21.  
  22. print(turtle.getFuelLevel() .. "/" .. turtle.getFuelLimit() .. " fuel")
  23. local tofill = turtle.getFuelLimit() - turtle.getFuelLevel()
  24. local amt = math.floor(tofill / 80)
  25. if amt > 0 then
  26.     print(amt .. " coal to refuel turtle")
  27. end
  28.  
Advertisement
RAW Paste Data Copied
Advertisement