lua-users home
lua-l archive

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

I would go with one of two options:
1) Assuming you just need to store Lua data with a userdata, consider
setting a new table as the environment for the userdata and using that
to store the data
2) If the userdatum need to have different metatables (e.g. they have
differing metamethods), then you could add a "__isTypeX" field to each
metatable, and use that to validate that the userdata are of the
correct type.

2008/6/1 Eike Decker <>:
> Hi
> Is there some "lua way" how to use the luaL_newmetatable functionality in
> combination with userdatas that need an individual metatable?
> In my case, I'd like to store a table together with the userdata to keep some
> lua variables that can be modified by the user. I thought about storing this
> table in the userdata's metatable. However, that model requires individual
> metatables for each userdata. However, this couldn't be used in combination
> with these functions. I could of course also use a table in the registry (or
> the metatable), using the userdata as keys.
> What would you suggest?
> Eike