Posted 03 April 2012 - 05:21 AM
Hello! I am trying to make an infinite loop in Lua. I've tried
::loop::
//code
goto loop
to no avail. Help!
::loop::
//code
goto loop
to no avail. Help!
while true do
stuff
end
theend = true
repeat
stuff
until theend == false -- will never be false so keeps repeating
function infiniteLoop()
while true do
stuff
end
end
infiniteLoop() -- to call the function
-- this should be fine, and it's what i use personally.
while true do
-- stuff
end
-- this should also be fine.
-- EDIT: oops, ninja'd.
repeat
-- stuff
until false
-- i would advise you stay away from this one.
-- it's valid, but definitely way above your level. plus i don't use it myself.
-- (the "return" is important - if you forget it, your program will crash horribly!)
do
local function f()
return f()
end
f()
end
While true do
--Stuff
end
function waitForTree()
turtle.select(1)
while true do
if (turtle.compare()) then
return
end
os.sleep(10)
end
end
function cutTreeDown()
-- Implement your chopping here...
end
function dropItems()
-- drop all items but except for 1 item from slot 1. (just assume its a log)
end
while true do
waitForTree()
cutTreeDown()
dropItems()
end