So I was trying to split my the lua file for the addon I’m working with into (at least) two parts. That way I can have the (mostly) static data in one part and the actual code that I’m tinkering with in the other.
From what I can see it should be straight forward but it’s not working for me. So far I’ve got
A TOC file that contains both lua files in the order they should be processed
CarnackiAddonData.lua
CarnackiMyAddonCode.lua
In CarnackiAddonData.lua looks like this (abbreviated since we don’t need hundreds of lines of data);
local CarnackiAddon, NS...
NS.CarnackiAddonDB = {[1]="Apples", [2]="Oranges", [3]="Bananas"};
In CarnackiAddonCode.lua I have (again abbreviated);
local CarnackiAddon, NS...
local CarnackiAddon = CreateFrame("Frame", nil, UIParent);
[various frame setup stuff that's all working]
local CarnackiAddonDBSize = 0;
local CarnackiAddonDBValue = "";
CarnackiAddonDBSize = NS.#CarnackiAddonDB;
CarnackiAddonDBValue = NS.CarnackiAddonDB[1];
print ("Size: "..CarnackiAddonDBSize);
print ("Value: "..CarnackiAddonDBValue);
So it should basically print two lines in the chat window;
Size: 3
Value: Apples
When it was in a single file it would do this, but from what I can tell I can’t use NS.#CarnackiAddonDB to do a count of the table anymore. I tested to make sure it’s reading the files ok by adding to CarnackiAddonCode.lua;
CarnackiNewDB = NS.CarnackiAddonDB;
CarnackiNewDBSize = #CarnackiNewDB;
print ("Size: "..CarnackiNewDBSize);
And that prints the DB size as expected. So it’s reading the values from both files properly. I can’t imagine that it’s efficient doing that as a workaround (especially once database size goes up). So how do I get the table count when I’m referring to a table in an included file?