local function func() for i = 1, 10 do if i == 1 then continue end -- skips to end of iteration when 'i' equals 2 print($"i = {i}") if i > 4 then break end -- exits the 'for' loop when 'i' exceeds 4 end for j = 1, 10 do print($"j = {j}") if j > 2 then goto label end -- jumps to 'label' when 'j' exceeds 2 end ::label:: for k = 1, 10 do print($"k = {k}") if k == 3 then return end -- returns from the function when 'k' equals 3 end end local function func2() print("starting") coroutine.yield() -- yields control back to the caller print("resuming") -- resumes here when called again end func() -- calls function local co = coroutine.create(func2) -- create coroutine coroutine.resume(co) -- start coroutine print("yielding") -- coroutine has yielded coroutine.resume(co) -- resumes coroutine