[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Passing functions addresses to tolua classes
- From: Björn De Meyer <bjorn.demeyer@...>
- Date: Mon, 03 Feb 2003 20:02:16 +0100
"jose_marin2 " wrote:
>
> Hi!
>
> Is there some way of do this?
> Later, I will call the function inside the method "doDomething". How
> to store the function to call it later? I know how to do using
> lua_ref, but how to do this with tolua "classes"?
In lua, functions are first-class values. You can store
them in variables just like other values. So just say:
function theClass:SetFunc(someFunc)
self.myfunc = someFunc
end
function theClass:doDomething()
if self.myfunc then
self.myfunc()
end
end
And you're all set. ^_^
--
"No one knows true heroes, for they speak not of their greatness." --
Daniel Remar.
Björn De Meyer
bjorn.demeyer@pandora.be