[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: userdata as table-key
- From: "Michaela Kyavar" <michaela.kyavar@...>
- Date: Sun, 25 Apr 2004 19:45:44 +0200
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