lua-users home
lua-l archive

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


Hello Lua Users!

Can you use userdata as a table key?

In the wiki Tables Tutorial, it states "You can use ANY Lua object as a key
in a table".

I need to associate a key (into a graphical wxLua control) with data.  The
key is returned as userdata.
So I would like to say something like

	CtrlTable[newId] = {icnt, jcnt, kcnt}
where

- CtrlTable is my table for lookups
- newId is the key that is userdata returned by the wxLua control
- {icnt, jcnt, kcnt} is the data (table) that I would like to store at
CtrlTable[newId].

When I do this, and then say
        print(string.format("Size of CtrlTable = %d",
table.getn(gCtrlTable )))

The result is 0.  Nor can I index the table using the newId key.  Where has
the data gone?


Thankyou,
M