Quote:Original post by Guy Meh
Technically, yes. My scripts in general are basically implementations of C++ methods except that (a) I don't want to have to recompile and (b) I want to program in a higher level language.
Why don't you simply prefix your function or use a table as name space?
C++
class NPC1 { void nextMove() { call_lua_function("NPC1.nextMove",this->state); } ...}
Lua
NPC1 = { nextMove = function(npc1_state) ... end, ...}-- for another type of NPCNPC2 = { nextMove = function(npc2_state) ... end, ...}
the Lua functions can access global variables and still have local variables in their own name space, the object specific variables are stored in the C++ class and passed to the Lua functions. Now you just need a function like "environment()" in Lua that returns information about the rest of world relevant for the NPCs. (Or send environment as second parameter)
You can also reuse some functions easily, for example
NPC3 = { -- behaves similar to NPC1 nextMove = NPC1.nextMove, ...}
This a non-OOP solution but very minimal and simple.