[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Store reference to a function to be called later
- From: Rob Kendrick <rjek@...>
- Date: Fri, 12 Aug 2011 13:43:49 +0100
On Fri, Aug 12, 2011 at 04:57:08AM -0700, Jose Marin wrote:
> I wouldn´t like to store the string "OnPlay", and make a search on the register for the function, would like to store the reference to the fucntion itself, to be directly called when the button is pressed.
> Any suggestions?
You can't take the actual reference to the function, as this would
defeat the garbage collector, as Lua won't know when your C code is done
Look at luaL_ref and _unref. These will give you an integer "handle" to
a Lua value that you can then store and easily lookup when you need to.