Thread Tools Display Modes
Prev Previous Post   Next Post Next
05/29/14, 09:21 PM   #1
Sharlikran
 
Sharlikran's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 655
Help with Complex Array.

Help with Complex Array.

Localization/HarvestMapData-en.lua
Localization/HarvestMapData-de.lua
Localization/HarvestMapData-fr.lua

I have three files in my manifest file listed like this. I have them that way to I can use a diff program like BeyoneCompare to line up the names so they are always in the exact sequence.


Lua Code:
  1. Harvest.langs = { "en", "de", "fr", }
  2. Harvest.DataStore = {
  3.    ["alikr"] = {},      --Alik'r Desert
  4.    ["auridon"] = {},    --Auridon, Khenarthi's Roost
  5.    ["bangkorai"] = {},  --Bangkorai
  6.    ["coldharbor"] = {}, --Coldharbour
  7.    ["cyrodiil"] = {},   --Cyrodiil
  8.    ["deshaan"] = {},    --"Deshaan"
  9.    ["eastmarch"] = {},  --Eastmarch
  10.    ["glenumbra"] = {},  --Glenumbra, Betnikh, Stros M'Kai
  11.    ["grahtwood"] = {},  --Grahtwood
  12.    ["greenshade"] = {}, --Greenshade
  13.    ["malabaltor"] = {}, --Malabal Tor
  14.    ["reapersmarch"] = {},  --Reaper's March
  15.    ["rivenspire"] = {}, --Rivenspire
  16.    ["shadowfen"] = {},  --Shadowfen
  17.    ["stonefalls"] = {}, --Stonefalls, Bal Foyen, Bleakrock Isle
  18.    ["stormhaven"] = {}, --Stormhaven
  19.    ["therift"] = {},    --The Rift
  20.    ["craglorn"] = {},    --Craglorn
  21. }
This is the beginning of my complex array. I am using code with permission from Undiscovered but I want to change it.
Lua Code:
  1. Harvest.DataStore["en"]["alikr"] = {
  2. --Alik'r Desert (Daggerfall, lvl 31-37)
  3.    ["alikr_base"] = {            --Alik'r Desert
  4.       --en
  5.       { "Aldunz", 3 },
  6. }
Then for the next part I want to define it that way. So that I can change the first part in the array to this.
Lua Code:
  1. Harvest.DataStore = {
  2.     ["alikr"] = Harvest.DataStore[Harvest.langs]["alikr"],
  3.     ........
  4. }
How can I structure it better? I want it to be something I could do a For loop on like this

Lua Code:
  1. for zone, zones in pairs(Harvest.DataStore) do
  2.     for lang, langs in pairs(zones) do
  3.         for subzone, subzones in pairs(langs) do
  4.             for map, maps in pairs(subzones) do
  5.                 d("Zone : " .. zone .. " : lang : " .. lang .. " : subzone : " .. subzone .. " : map : " .. map)
would return this

Zone : alikr : lang : en : subzone : alikr_base : map : Aldunz

Lua Code:
  1. Harvest.DataStore["alikr"]["en"]["alikr_base"] = {            --Alik'r Desert
  2.       --en
  3.       { "Aldunz", 3 },
  4. }
How can I accomplish that result, I fear I am doing something terribly wrong.

Lua Code:
  1. Harvest.DataStore["en"]["alikr_base"] = {
  2.     --Alik'r Desert (Daggerfall, lvl 31-37)
  3.     --Alik'r Desert
  4.       --en
  5.       { "Aldunz", 3 },
  6. }
  7.  
  8. Harvest.DataStore = {
  9.    ["alikr"] = {Harvest.DataStore["en"]["alikr_base"],
  10.                 Harvest.DataStore["de"]["alikr_base"],
  11.                 Harvest.DataStore["fr"]["alikr_base"]}  --Alik'r Desert
Something like that maybe?

EDIT: Nope none of my variations are working.

Last edited by Sharlikran : 05/29/14 at 10:42 PM.
  Reply With Quote
 

ESOUI » Developer Discussions » Lua/XML Help » Help with Complex Array.


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off