LUA - How to interface Bmax Class,method and field

BlitzMax Forums/BlitzMax Beginners Area/LUA - How to interface Bmax Class,method and field

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

Gabriel,

no, you HAVE to create a Handle for every object in order to "tell" BlitzMax's internal garbage collection that the object is still required. Otherwise, the BlitzMax object might silently be removed from memory some time, let the Lua userdata pointer point to nonsense and lead to strange results.

Of course, if you REALLY know, that your object will survive beause it is already referenced by BlitzMax itself, then you could do without Handles. But be VERY careful!

Personally, I prefer the Handle-based approach and let the Lua garbage collector "release" it as soon as it is no longer needed (using the __gc metamethod and an invocation of a corresponding BlitzMax method)