turtle.getFuelLevel

From ComputerCraft Wiki
Revision as of 14:24, 21 April 2015 by MisterSanderson (Talk | contribs) (Clarifying what is fuel level, and adding a note about loosing fuel.)

Jump to: navigation, search


Grid Redstone.png  Function turtle.getFuelLevel
Returns how much fuel is inside the specific turtle. Turtles may be configured to ignore the need for fuel via ComputerCraft.cfg, in which case this command will always return "unlimited". Turtles loose their fuel when destroyed, if they don't have a label.

See also: turtle.refuel(), turtle.getFuelLimit()
Syntax turtle.getFuelLevel()
Returns "unlimited" if fuel is disabled, otherwise the fuel level.
Part of ComputerCraft
API turtle

Examples

Grid paper.png  Example
Attempts to refuel the turtle if the fuel tank is empty.
Code
if turtle.getFuelLevel() ~= "unlimited" and turtle.getFuelLevel() < 1 then
	turtle.refuel()
end