How do I call a function if I didn't define it earlier in the code?

I have a generation function in the code, it generates something. I call it at the start and it works. However, I need to regenerate again and I call the function, although it is not defined, how do I always call the function so that there are no such errors in solar 2d?

I’ve tried swapping functions, but when I put one ahead, another error occurs, meaning I can’t do either.

Hi, maybe you are looking for forward declarations?

local a,b

a = function()
    print("a")
    b()
end

b = function() print("b") end

a()

1 Like

If I understood you correctly:

If you make it global you can call it from anywhere but it is not recommended

to make it global remove the local declaration before the function name

1 Like