Greets all,
In the script I'm working with, I've created several tables. I would like to associate several of them with a metatable I've created.
However, I would like to avoid having to manually associate each of these tables with the metatable as this is time consuming. Especially if I decide to add several more tables in the future.
I am curious if there is a way to iterate through all the tables that have been created in the script. I know that lua must store a list of its tables that have been created somewhere, is there a way to access that list?
All the tables I want to associate with my metatable end with _list. ie. name_list, class_list, cure_list. So I was thinking there must be a way to iterate through the list of tables that has been created and run an IF statement to associate them with the metatable, as so:
Any thoughts on how this might be achieved?
In the script I'm working with, I've created several tables. I would like to associate several of them with a metatable I've created.
However, I would like to avoid having to manually associate each of these tables with the metatable as this is time consuming. Especially if I decide to add several more tables in the future.
I am curious if there is a way to iterate through all the tables that have been created in the script. I know that lua must store a list of its tables that have been created somewhere, is there a way to access that list?
All the tables I want to associate with my metatable end with _list. ie. name_list, class_list, cure_list. So I was thinking there must be a way to iterate through the list of tables that has been created and run an IF statement to associate them with the metatable, as so:
if string.sub(tablename, -4) == "list" then
setmetatable(tablename, mt) -- mt is the name of the metatable I've created
endAny thoughts on how this might be achieved?