Where am I going wrong with this code?
Solution 1:
Looking at the Turtle API you will see the getFuelLimit()
is only implemented in version 1.6, and you are running version 1.57.
From the wiki:
Added by version 1.6 of ComputerCraft, this command returns the maximum amount of fuel a turtle may store. By default, a regular turtle may hold 20,000 units, and an advanced model 100,000 units; both values can be changed in ComputerCraft.cfg.
In builds prior to 1.6, turtles may store practically unlimited amounts of fuel.
Solution 2:
to make it forward compatible you can do the following:
function getFuelLimit()
if turtle.getFuelLimit ~= nil then
return turtle.getFuelLimit()
else
return 0;
end
end
and add a check for 0 when checking the fuel against it or set your own fuel limit