lua-users home
lua-l archive

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


Is there anyway to actually make a variable nil indirectly without
having to do the usual 'variable name = nil' in LUA? 

For example I have a variable called MyObject which I instantiate in a
table, later in the code I wish to destroy all
references to it so I may use something like the following

MyObject = {}
...
MyObject is created and setup + instantiated and filled in with params C
side..
...

function DestroyObject( a )
	a:Destroy()
	a = nil
end;

DestroyObject( MyObject )

Its destroy function is called, but it does not make MyObject nil?

If I do the following

MyObject:Destroy()
MyObject = nil

Everything works fine...

So 2 questions

1) Is it possible to call a function in lua and pass in a reference to
an object and set that object to nil like above?

2) Is it possible to make MyObject = nil from C, I have tried setting
MyObject to nill using pushnil etc and removing all references in tables
to this object but it still remains in lua..

Regards