I'm a little confused regarding local functions in Lua. Please have a look at this following, simplified example.
function test()
local function f()
print("f")
g()
end
local function g()
print("g")
end
f()
end
test()
Upon running this code, I get an error in function "f", because function "g" is a nil value. From my understanding, both functions should have been declared once the code reaches the call to function "g", and since both functions have not yet reached the end of the block they're in (function "test"), they should still be accessible. This code works fine when declaring the functions as global, and I'm really not sure why it doesn't work with local functions. The book "Programming in Lua" didn't help me either.