On Mon, Mar 22, 2010 at 4:27 AM, Christopher Eykamp <chris@eykamp.com
<mailto:chris@eykamp.com>> wrote:
// hide metatable from Lua getmetatable()
lua_pushvalue(L, methods);
set(L, metatable, "__metatable");<--- metatable is index of a
new metatable
The code above is what is preventing you from adding metamethods in
Lua. Lunar lets you add plain methods in Lua, but not metamethods.
That code is returning the methods table when you call getmetatable.
An example:
Lua 5.1.4 Copyright (C) 1994-2008 Lua.org, PUC-Rio
> a = {}
> setmetatable(a, {__metatable="hi there"})
> print(a)
table: 00717E20
> print(getmetatable(a))
hi there
So you´ll need to comment those two lines or devise some way to inject
arbitrarily methods in the metatable before "sealing" it.