[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: test
- From: lukey@... (Jens Hassler)
- Date: 07 Nov 2004 09:29:00 +0200
I am using Lua a lot in my game with great success. I exposed my game
API via toLua to my scripts. But now I have a "typical" C/pointer
In my script I do something like that:
my_enemy = enemy_class:create_enemy()
This returns a userdata (?) pointing to the enemy object which was
created by the C++ function create_enemy.
Now this enemy is destroyed and deleted inside the C++ code and
"my_enemy" is pointing to neverland (and causing a crash when accessed).
So, is there an "elegant" way to set such rogue userdata objects to nil?
Actually I work around this problem with calling a "enemy_dead()" LUA
function from C code when an enemy object is about to be destroyed. In
this function I'm looping through my globals and set the ones pointing
to the enemy to nil.
It'd be perfect If I could reset these variables directly from my C++
code so that all Lua userdata objects will point to nil when the enemy
Thanks for your help.