06-18-2012, 05:00 AM
Problems, problems everywhere.
To test the new ForEach functions I tried implementing a KillPickups command that would destroy all pickups within a chunk. But there's a problem:
- The only place where Lua can get a valid cEntity pointer is inside the callback function
- It isn't safe to call cEntity::Destroy() inside the callback function, because it breaks the entity enumeration
So how do I destroy entities in Lua?
I guess there's one more function I need to do - cWorld::QueueDestroyEntity(), accessible from Lua. And remove cEntity:Destroy() from Lua interface, since it's useless there. Oh man, it's getting difficult.
To test the new ForEach functions I tried implementing a KillPickups command that would destroy all pickups within a chunk. But there's a problem:
- The only place where Lua can get a valid cEntity pointer is inside the callback function
- It isn't safe to call cEntity::Destroy() inside the callback function, because it breaks the entity enumeration
So how do I destroy entities in Lua?
I guess there's one more function I need to do - cWorld::QueueDestroyEntity(), accessible from Lua. And remove cEntity:Destroy() from Lua interface, since it's useless there. Oh man, it's getting difficult.