lua-users home
lua-l archive

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




On 3/22/2010 4:44 AM, Ignacio Burgueño wrote:
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.

Great, that I can do.

Thanks to everyone who helped, and as soon as I get my machine fixed, I'm going to try this!

Chris