Difference between revisions of "Turtle.getFuelLevel"

From ComputerCraft Wiki
Jump to: navigation, search
m (Moved to CAT:LuaCoreFunctions)
(Wiki table.)
Line 1: Line 1:
<table style="width: 70%; border: solid 2px black; margin: 2px; padding: .3em; border-spacing: 0px;">
+
{{lowercase}}
<tr><td colspan="2" style="font-weight: bold; font-size: large; padding-bottom: .3em; border-bottom: solid black 1px;">Function turtle.getFuelLevel</td></tr>
+
{{Function
<tr style="background-color: #E8E8E8;"><td style="border-right: solid black 1px; padding: .2em; width: 10%; font-weight: bold;">Syntax</td>
+
|name=turtle.getFuelLevel
<td style="border-color: black; padding: .2em; padding-left: .4em;">turtle.getFuelLevel()</td></tr>
+
|api=turtle
<tr style="background-color: #FFFFFF;"><td style="border-right: solid black 1px; padding: .2em; width: 10%; font-weight: bold;">Returns</td>
+
|returns="unlimited" if fuel is disabled, otherwise the fuel level.
<td style="border-color: black; padding: .2em; padding-left: .4em;"> "unlimited" if fuel is disabled, otherwise the fuel level.</td></tr>
+
|addon=ComputerCraft
<tr style="background-color: #E8E8E8;"><td style="border-right: solid black 1px; padding: .2em; width: 10%; font-weight: bold;">Part of</td>
+
|desc=Returns the [[fuel]] level. Turtles may be configured to ignore the need for fuel via [[ComputerCraft.cfg]], in which case this command will always return "unlimited".<br><br>
<td style="border-color: black; padding: .2em; padding-left: .4em;">[[ComputerCraft]]</td></tr>
+
 
<tr style="background-color: #FFFFFF;"><td style="border-right: solid black 1px; padding: .2em; width: 10%; font-weight: bold;">API</td>
+
See also: [[Turtle.refuel|turtle.refuel()]], [[Turtle.getFuelLimit|turtle.getFuelLimit()]]
<td style="border-color: black; padding: .2em; padding-left: .4em;">[[turtle]]</td></tr>
+
|examples=
<tr style="background-color: #E8E8E8;"><td style="border-right: solid black 1px; padding: .2em; width: 10%; font-weight: bold;">Description</td>
+
{{Example
<td style="border-color: black; padding: .2em; padding-left: .4em;">Returns the fuel level.</td></tr>
+
|desc=Attempts to refuel the turtle if the fuel tank is empty.
</table>
+
|code= if turtle.getFuelLevel() ~= "unlimited" and turtle.getFuelLevel() < 1 then
<h2> <span class="mw-headline" id="Examples"> Examples </span></h2>
+
turtle.refuel()
<table style="border-spacing: 0px;">
+
end
<tr>
+
}}
<td style="padding-right: .5em; border-right: solid #DDD 1px; border-bottom: solid #DDD 1px;"><b>Description</b></td>
+
}}
<td style="padding-left: .5em; border-bottom: solid #DDD 1px;">Fills the turtle with fuel if the fuel tank is empty</td>
+
</tr>
+
<tr>
+
<td style="padding-right: .5em; border-right: solid #DDD 1px;"><b>Code</b></td>
+
<td style="padding-left: .5em;">
+
<pre>if turtle.getFuelLevel() < 1 then
+
turtle.refuel()
+
end
+
</pre>
+
</td>
+
</tr>
+
<tr>
+
<td style="padding-right: .5em; border-right: solid #DDD 1px;"><b>Output</b></td>
+
<td style="padding-left: .5em;">Checks if the fuel tank is empty, if it is, it will fill the tank, otherwise it won't do anything.</td>
+
</tr>
+
</table>
+
  
 
[[Category:Lua_Core_Functions]]
 
[[Category:Lua_Core_Functions]]

Revision as of 02:21, 29 March 2014


Grid Redstone.png  Function turtle.getFuelLevel
Returns the fuel level. Turtles may be configured to ignore the need for fuel via ComputerCraft.cfg, in which case this command will always return "unlimited".

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