How would I namespace a Lua AI, and separate it into separate files?
I am making an AI with lots of functions. To be maintainable it needs to be separated into different files based. How would I do this?
Also how would I namespace these functions so they do not conflict with other functions?
Namespace a Lua gadget/AI
Moderator: Moderators
Re: Namespace a Lua gadget/AI
You put all your public functions and variables into a table.
You make the "library" lua file return that table.
You make the "parent" lua file put the result of the include into a table.
Then, instead of local names in a namespace, you use named fields of your table. If all your methods have self as their first argument, you can even use the : almost like in C namespaces!
You make the "library" lua file return that table.
You make the "parent" lua file put the result of the include into a table.
Then, instead of local names in a namespace, you use named fields of your table. If all your methods have self as their first argument, you can even use the : almost like in C namespaces!