For my game in C++ I'm using different objects (like player, enemy, et cetera) which will have to be controlled by a Lua script. My problem is that if I were to write a function in my player script, all my other scripts will have access to it as well, and I don't want that.
I can think of three basic solutions:
- For every iteration clear the entire state and re-register everything
- Determine out what functions a script registers and remove them
- Have every gameobject running it's own Lua state
Is there a good way to do this, keeping runtime performance in mind?
local
keyword? According to this page, you should always use local unless another part of the program needs to access that particular variable/function. \$\endgroup\$