This will probably work better.
Lua Code:
local function FillTableStructure(tbl,...)
-- Check if sent a table and cache for return
tbl=tbl or {};
local ret=tbl;
for i=1,select("#",...) do
local idx=select(i,...);-- Index from argument list
local entry=tbl[idx];-- Cache current entry if any
-- Make table and link to index if not exist
if not entry then
entry={};
tbl[idx]=entry;
end
tbl=entry;-- Select entry as current table
end
return ret;
end
-- If the table was a local, you can run the function like this
ADVANCED_INTERFACE_GLOBAL_CONSTANTS=FillTableStructure(ADVANCED_INTERFACE_GLOBAL_CONSTANTS,"STAMPS","ADVANCED_USER_INTERFACE");
-- If the table was a global, you technically could give it _G as the base table or use the same line above
FillTableStructure(_G,"ADVANCED_INTERFACE_GLOBAL_CONSTANTS","STAMPS","ADVANCED_USER_INTERFACE");
Unlike Barjack's function, this keeps existing entries and allows numeric and object keys. It's still much less efficient than Torhal's code.