lua-users home
lua-l archive

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


Graham Wakefield wrote:
Hi all,

I'm having trouble using __call in a metatable for userdata; is this supported?

Yes.


Here's a rough sketch:

print(Noise)
table.foreach(Noise, print)
noise = Noise()

Noise is a metatable. You create a userdata, setmetatable it to the Noise table, and then call the userdata. (No need to expose Noise
to the Lua environment.)