Posted 28 August 2016 - 07:08 AM
Hello, I'm brand-spankin' new on the forum.
I read the "FAQ" post and, forgive me if I'm wrong, don't see if any of it applies to my loop. That being said, I have a mining turtle program that will dig a tunnel of my preferred height over the 'tunnel' program. Within it is a "wait to refuel" function that, of course, waits for fuel to be dumped into the inventory of the turtle. It looks like so:
Unfortunately the problem I'm having is the turtle, when out of fuel, gets to the point where it prints "Waiting for fuel." and prints that. Then it appears to run the while loop ("while(turtle.getFuelLevel() < 6") a single time and then begins the mining functions below this function (Of course it's not able to do any movement forward so it just moves up and down doing turns and ups and downs alone). I'm guessing something is wrong with the while loop, which would make me feel a tad worthless, or there's something wrong with an infinite loop running waiting for a change in inventory.
What am I doing wrong here?
I read the "FAQ" post and, forgive me if I'm wrong, don't see if any of it applies to my loop. That being said, I have a mining turtle program that will dig a tunnel of my preferred height over the 'tunnel' program. Within it is a "wait to refuel" function that, of course, waits for fuel to be dumped into the inventory of the turtle. It looks like so:
function fuelCheck()
if(turtle.refuel(0)) then
turtle.refuel(1)
else
print("Waiting for fuel.")
while(turtle.getFuelLevel() < 6) do
for i = 1, 16 do
turtle.select(i)
turtle.refuel(1)
end
end
end
end
//mining functions here...
Unfortunately the problem I'm having is the turtle, when out of fuel, gets to the point where it prints "Waiting for fuel." and prints that. Then it appears to run the while loop ("while(turtle.getFuelLevel() < 6") a single time and then begins the mining functions below this function (Of course it's not able to do any movement forward so it just moves up and down doing turns and ups and downs alone). I'm guessing something is wrong with the while loop, which would make me feel a tad worthless, or there's something wrong with an infinite loop running waiting for a change in inventory.
What am I doing wrong here?