Posted 26 May 2013 - 05:43 AM
for example:
function name()
name()
end
function name()
name()
end
function name()
-- code
end
while true do
name()
end
local function foobar()
print("foobar")
end
With:foobar()
local function foobar()
if something then
return
end
print("foobar")
end
return "It did not work!"
--# and catch the string
local s = foobar()
local runAgain = true
local function name()
if runAgain then
runAgain = false
name()
end
print('Hello')
end
name()
Hello
Hello
program calls `name`
if statement is true, `name` calls `name`
second `name` prints "Hello"
second `name` finishes
program returns back to first `name`
first `name` prints "Hello"
first `name` finishes
program finishes
local runAgain = true
local function name()
if runAgain then
runAgain = false
return name()
end
print('Hello')
end
name()
Hello
program calls `name`
if statement is true, `name` calls `name`
second `name` prints "Hello"
second `name` finishes
program returns back to first `name`
first `name` returns back to program
program finishes