100 posts
Posted 28 January 2013 - 09:11 AM
function fuel()
for f = turtle.getFuelLevel()
while f < 56 do
wait(30)
end
end
function uturn()
turtle.turnRight()
turtle.turnRight()
end
fuel()
uturn()
i'm working on a small script but i'm kind of new. the error i get is on line 3 apparently?
::edit:: my problem was i had FOR on line 2. can somebody explain to me why this was causing an error?
1522 posts
Location
The Netherlands
Posted 28 January 2013 - 09:34 AM
function fuel()
for f = turtle.getFuelLevel()
while f < 56 do
wait(30)
end
end
function uturn()
turtle.turnRight()
turtle.turnRight()
end
fuel()
uturn()
i'm working on a small script but i'm kind of new. the error i get is on line 3 apparently?
::edit:: my problem was i had FOR on line 2. can somebody explain to me why this was causing an error?
This is causing a problem because for is intianting a loop. The syntax for this is: for i = 1, variable, step do [your code] end. Step is by default 1
Example:
for i = 1, 10 do
print(i)
end
for i = 1,10,2 do
print(i)
end
Try those out and you will know how it works :)/>
2088 posts
Location
South Africa
Posted 28 January 2013 - 09:41 AM
remove the 'for' from for k = turtle.getFuelLevel() and it should work. Also wait() is not a valid function unless you made one, but sleep() is what you're looking for. And you may want it to refuel while it's sleeping so it will not sleep for infinity
3 posts
Posted 28 January 2013 - 10:05 AM
You could try doing
function fuel()
while turtle.getFuelLevel() < 56 do
wait(30) --unless you made a function named wait(), you'd wanna do sleep(30)
end
end
function uturn()
turtle.turnRight()
turtle.turnRight()
end
fuel()
uturn()
like remiX said, you might want it to refuel while the turtle is waiting/sleeping, else it'd sleep for eternity.