Posted 23 December 2012 - 04:38 PM
Hi, I am new to lua code, and was wondering if I can make an If/then statement within a function.
Right now I am trying to make a turtle refuel itself within a program.
Here is my code so far:
Or I was thinking of loops in VB language and came across the repeat, so here is another idea:
So, first off, can I put an if/then or repeat statement within a function? If so how would I correct my code?
Thank you in advance!
Right now I am trying to make a turtle refuel itself within a program.
Here is my code so far:
function fuel() return
if turtle.getFuelLevel() < 300 then
turtle.refuel(1)
fuel()
else
print("Fueled Up!")
end
end
print "Checking Fuel..."
fuel()
Or I was thinking of loops in VB language and came across the repeat, so here is another idea:
function fuel() return
repeat turtle.refuel(1) until
turtle.getFuelLevel() > 300
end
print("Checking Fuel")
fuel()
print("Fueled Up!")
So, first off, can I put an if/then or repeat statement within a function? If so how would I correct my code?
Thank you in advance!