Is it possible to use a for loop to dynamically name variables? Something such as:
t = {}
For i in ipairs(tablename) do
t.i = something
End
My actual problem consists of dynamically creating protofields for a wireshark dissector, but if the above is not possible, I doubt the protofield problem will be possible
Just do
t[i]
. This will index the table (t
) with a valuei
.(Note that in Lua,
foo.bar
is short forfoo["bar"]
. Also note that the string"123"
is different from the number123
)