233 posts
Location
Cleveland, Ohio
Posted 09 March 2013 - 04:58 PM
i don't know what is wrong with this code, it says it expects end to close for but there is an end!
function sf(args)
gas = turtle.getFuelLevel()
if args < gas then
for i=1, args do
turtle.forward()
else
print("no fuel")
[size=4]end[/size]
end
end
Please tell me the error! thank you
892 posts
Location
Where you'd least expect it.
Posted 09 March 2013 - 05:02 PM
REmove an end from the end and put it before the else.
1511 posts
Location
Pennsylvania
Posted 09 March 2013 - 05:04 PM
Ah, my eyes. It burns! Poor indentation.. can't breathe.. help me immibis!
8543 posts
Posted 09 March 2013 - 05:05 PM
function sf(args)
gas = turtle.getFuelLevel()
if args < gas then
for i=1, args do
turtle.forward()
end
else
print("no fuel")
end
end
233 posts
Location
Cleveland, Ohio
Posted 09 March 2013 - 05:16 PM
thank you, and yes i know, i dont really understand the indenting
1511 posts
Location
Pennsylvania
Posted 09 March 2013 - 05:20 PM
Indentation deprivation!
19 posts
Location
Eating a cake from the inside out.
Posted 09 March 2013 - 05:20 PM
function checkFuel(arg1)
if type(arg1) == "number" then
local fuel1, fuel2 = turtle.getFuelLevel()
if fuel1 >= arg1 then
return true
else
return false
end
else
return false
end
end
Will return if you can move the ammount of blocks you said in arg1… Will return true for can move or false if it cant or the input isnt a integer.
(Not Tested)
233 posts
Location
Cleveland, Ohio
Posted 09 March 2013 - 05:27 PM
ok new error, it says a nil value when i try to run the function help?
19 posts
Location
Eating a cake from the inside out.
Posted 09 March 2013 - 05:29 PM
Try this..
function checkFuel(arg1)
local fuel1, fuel2 = turtle.getFuelLevel()
if fuel1 >= arg1 then
return true
else
return false
end
end
2005 posts
Posted 09 March 2013 - 05:31 PM
What line?
Also, provide the current code of the function you're trying to use.
Edited on 09 March 2013 - 04:33 PM