[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Nil-ing userdata
- From: David Pirrò <david.pirro@...>
- Date: Fri, 22 Oct 2010 19:18:05 +0200
I'm quite new to lua, so pardon me if this is a stupid/ old question.
I'm currently embedding lua in a C++ programm I've written.
I've used a version of lunar.h to bind my C++ objects to lua, by using userdatas (with all the necessary methods in the metatable, like "__gc" and so on...) containing the pointer to the C++ objects.
Everything (with a little work...) is going well until now.
But now I have a problem.
I have to objects in lua:
s = Scene:new();
m = Mass:new(s); \\ mass that belongs the scene "s"
I want to explicitly delete such an object from lua code in this way:
deleting the C++ object is no problem.
But how do I "force" lua to garbage collect the "m" object?
That would be something like:
m = nil;
but in one call.
Can I set the "m" userdata to nil from the lua C API?
Hope that's somehow clear...
Thank you very much for your help.