Posted 25 August 2016 - 05:57 AM
So I'm following along with Direwolf20's CC basics tutorial series, and I'm on loops.
I've got the program to make the turtle move forward the number of blocks you input, and I understand that.
So, I figured I would try to figure out how to implement a simple "Not Enough Fuel" mechanic, which would make the turtle not move, and instead print "Not enough fuel!" if the number entered is greater than it's remaining fuel level.
This is the code, and to me (a 100% noob to Lua) it seems right.
However, the problem is, it will only display "Not enough fuel" if the fuel level is 0.
I fueled it with 1 coal (80 fuel), and told it to go 100 blocks, and it happily went along.
So, what's going wrong here? Does turtle.getFuelLevel actually only return true and false? Or, am I missing something obvious? Sorry if it's something stupid :P/>
Thank you!
I've got the program to make the turtle move forward the number of blocks you input, and I understand that.
So, I figured I would try to figure out how to implement a simple "Not Enough Fuel" mechanic, which would make the turtle not move, and instead print "Not enough fuel!" if the number entered is greater than it's remaining fuel level.
This is the code, and to me (a 100% noob to Lua) it seems right.
term.write("How many blocks?: ")
blocks=read()
for i=1, blocks do
while turtle.getFuelLevel()<i do
print("Not Enough Fuel!")
break
end
while not turtle.forward() do
turtle.dig()
end
end
However, the problem is, it will only display "Not enough fuel" if the fuel level is 0.
I fueled it with 1 coal (80 fuel), and told it to go 100 blocks, and it happily went along.
So, what's going wrong here? Does turtle.getFuelLevel actually only return true and false? Or, am I missing something obvious? Sorry if it's something stupid :P/>
Thank you!