I want a to call a function that is defined in main.lua from a module that is required (included) in main.lua. What's the best/cleanest way to do this?
Edit:
I eventually went down the dispatch event route. That seems to be a neat way of doing it.
There are two options as far as I can see:
require() the module, and call function A there.require() the module first, and have the module define a function B that calls the function A in your main file. Call function B whenever you are ready to call it (i.e. function A is defined) in your main file.The latter seems cleaner, but that would be a matter of personal preference.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With