lua-users home
lua-l archive

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

Hello Jose,

Usually it will be advisable to avoid decoupling the lua state too much from the internal host state if possible. We use light userdata values to exclusively pass persistent, unique indices (into internal lists of buildings, characters, vehicles etc.) to lua scripts (reserving a few of the most significant bits of each ulong for datatype validation flags). The usage of a unique identifier (on a per 'datatype' basis) makes it a trivial task to check whether a given object reference is still valid (a character may have died, but it's easy to validate that the specific character is no longer present in the host state). In short, decoupling the script state from the host state where short-lived references are concerned (like 'shots' for instance) is probably not the best strategy. If, for instance, you want the application of character damage scriptable, maybe a callback function taking a character and damage info is a better idea. If you're using c++, I recommend stl containers for your entity lists.



At 13:15 09-06-2004, you wrote:

In most games, there are many objects created and
destroyed, for example, enemies, shots, missiles, etc.

How do you manage this? How do you mantain the object
list, avoiding create and destroy objects?

Use lists?


Participe da pesquisa global sobre o Yahoo! Mail: