Difference between revisions of "Turtle.getFuelLevel"

From ComputerCraft Wiki
Jump to: navigation, search
(Fixed Redlinks)
 
(4 intermediate revisions by 3 users not shown)
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 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]].<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>
+
Trivia: during the 1.4 beta, [[turtle.getFuelLevel]]() in softcore (that is now <var>turtleneedsfuel = 0</var>) returned 9000.
<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>
+
==See also==
<tr>
+
*[[Turtle.refuel | Turtle.refuel()]]
<td style="padding-right: .5em; border-right: solid #DDD 1px;"><b>Code</b></td>
+
*[[Turtle.getFuelLimit | Turtle.getFuelLimit()]]
<td style="padding-left: .5em;">
+
 
<pre>if turtle.getFuelLevel() < 1 then
+
[[Category:Lua_Core_Functions]]
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>
+

Latest revision as of 04:23, 31 July 2015


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.

Trivia: during the 1.4 beta, turtle.getFuelLevel() in softcore (that is now turtleneedsfuel = 0) returned 9000.
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


See also