This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
jay5476's profile picture

Is There A Way To See If A Move Requires Fuel

Started by jay5476, 17 September 2013 - 09:23 AM
jay5476 #1
Posted 17 September 2013 - 11:23 AM
im wondering if there is a way to detect if a move requires fuel without actually trying it, or will I have to put all moves that do in a table?
theoriginalbit #2
Posted 17 September 2013 - 12:02 PM
If fuel is disabled then turtle.getFuelLevel will return "unlimited", if the function doesn't exist then the version of CC doesn't have the fuel requirement, other than that, any time a Turtle moves from one block to another it requires fuel. Nothing like turning the Turtle does.

So a good fuel checking function would be

local function enoughFuel( required )
  --# if the function doesn't exist exit the function
  if not turtle.getFuelLevel then
    return true
  end
  --# get the fuel level
  local fuel = turtle.getFuelLevel()
  --# return whether the fuel is unlimited or there is fuel to move
  return fuel == "unlimited" or fuel >= required
end