I hope someone here can help me, because the "official" Lua-forum is so inactive, that posting there is pointless.
I do "OOP" (if one can call it that) with Lua. Ie:
a =
{
member = 20
}
function a:foo (sender, value)
print (value)
sender:bar (value * 2)
end
Suppose, that "a" wants to call "bar" on "sender", if it exists. However, if "bar" does not exist, the function call should be ignored and NOT RAISE AN ERROR.
I tried setting the "__call" metamethod for every "class" to handle the situation that "sender.bar" is a nil-value. However, my "__call" metamethod seems never to be called itself. Instead my application tells me, through "lua_pcall", that an error occured.
I tried something like this (for every class):
self.__call = function (func, ...)
if (type (func) == "function") then
func (...)
else
print ("catched call to a non-existing function")
end
end
Any ideas, how to do this?
Thanks,
Jan.












