lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Hallo,

Tim Conkling wrote:

[...]
I'm having trouble figuring out how to get this all working in Lua without creating a separate Lua state for each entity. I'd like all entities to operate within the same state for speed concerns. Each script file will be like a C++ class: it will declare instance variables that are used by each entity that uses that script file to define its behavior, and it will define functions that operate on that data. Each game entity will be like a C++ object -- it will have its own copies of the instance variables defined by its associated script file, and functions called on that object will manipulate the object's instance variables. But since multiple script files can define the same functions, and since multiple entities can use the same script file, I'm not sure how to keep all the data organized in one Lua state. Any thoughts? Should I be approaching this problem from a different direction?


Why don't you put all the functions and variables of each single entity in a table?

-Alex