Mostly working

His Dad [09-28-16 - 06:40]
Mostly working
Filename
HistOffline.lua
data/Group1.lua
data/Group2.lua
diff --git a/HistOffline.lua b/HistOffline.lua
index 2af8be7..964f627 100644
--- a/HistOffline.lua
+++ b/HistOffline.lua
@@ -154,6 +154,10 @@ for acc,_ in pairs(History_SV["Default"]) do

 -- Load Character Data
 	for playerID, _ in pairs(History_SV["Default"][acc]["$AccountWide"]["data"]) do
+
+		if playerID == "" then
+		print("acct: " .. acc)
+		end
 		table.insert (accounts[acc].playerIDs, playerID)
 		accounts[acc].player[playerID] = {}		-- stub table to hold char data, later becomes "me"
 --
@@ -287,11 +291,13 @@ end
   dung = accounts[acc].dung
   dung.pub = {}
   dung.Grp = {}
+  dung.trials = {}
+  dung.DLC = {}

   for _,i in ipairs(Grp_Order) do
 	dung.Grp[i]= {}
 	dung.Grp[i].key ={}   -- key lookup
-	dung.Grp[i].box = iup.matrix {numcol=#accounts[acc].playerIDs,  numlin=_size(Grp_Dat[i].dat), widthdef=100}
+	dung.Grp[i].box = iup.matrix {numcol=#accounts[acc].playerIDs,  numlin=_size(Grp_Dat[i].id), widthdef=100}
 	dung.Grp[i].tab = iup.vbox {
 						["tabtitle"] =L.Grp_TabName[i],
 						dung.Grp[i].box,
@@ -313,20 +319,22 @@ end
 	iup.SetAttribute(dung.Grp[i].box, "READONLY", "YES")
   end

-  dung.trials = {}
-  dung.DLC = {}
-
-
   -- a table for each dungeon to which we add characters
   for _,i in ipairs(Grp1_Order) do
-    for _,j in ipairs(grp1tokey) do
-	  dung.Grp[i].key[j] = {}
+    for _,key in ipairs(grp1tokey) do
+	  dung.Grp[i].key[key] = {}
+	  for _,playerID in ipairs(accounts[acc].playerIDs) do
+		dung.Grp[i].key[key][playerID] = false
+	  end
 	end
   end

   for _,i in ipairs(Grp2_Order) do
-    for _,j in ipairs(grp2tokey) do
-	  dung.Grp[i].key[j] = {}
+    for _,key in ipairs(grp2tokey) do
+	  dung.Grp[i].key[key] = {}
+	  for _,playerID in ipairs(accounts[acc].playerIDs) do
+		dung.Grp[i].key[key][playerID] = false
+	  end
 	end
   end

@@ -413,14 +421,14 @@ end

 			-- set text to black if achievement found.

-			for id,_ in pairs (Grp_Dat[i]) do
+			for id, Gdat in pairs (Grp_Dat[i].id) do
 				local colour,key
 				if thischar.ach[id] ~= nil then
-					colour = "FGCOLOR" .. Grp_Dat[i][id].dat.L .. ":" .. Grp_Dat[i][id].dat.C
+					colour = "FGCOLOR" .. Gdat.L .. ":" .. Gdat.C
 					iup.SetAttribute(me.Grp[i].box, colour, FG_Colour_Complete)
 					-- Add char to dungeon
-					key = tostring(Grp_Dat[i][id].dat.L .. Grp_Dat[i][id].dat.C)
-					dung.Grp[i][key][playerID] = "Y"
+					key = tostring(Gdat.L .. Gdat.C)
+					dung.Grp[i].key[key][playerID] = true
 				end
 			end

@@ -446,11 +454,9 @@ end
 		end

 		for _,i in ipairs(Grp_Order) do
-			for _, id in pairs (Grp_Dat[i].dat) do
-					local L = id.L
-					local C = id.C
-					local key = tostring(L).. tostring(C)	-- make name key
-					me.Grp[i].box:setcell(L, C, grp_names[key])
+			for _, id in pairs (Grp_Dat[i].id) do
+				local key = tostring(id.L).. tostring(id.C)	-- make name key
+				me.Grp[i].box:setcell(id.L, id.C, grp_names[key])
 			end
 		end

@@ -480,7 +486,7 @@ end
 				iup.SetAttribute(me.Pub_box, colour, FG_Colour_Complete)
 				-- Add char to dungeon
 				local key = tostring(Pub_Dat.dat[id].L .. Pub_Dat.dat[id].C)
-				dung.pub.key[key][playerID] = "Y"
+				dung.pub.key[key][playerID] = true
 			end
 		end

@@ -497,17 +503,15 @@ end
 		end

 		for id,dat in pairs (Pub_Dat.dat) do  -- Load text
-				local L = dat.L
-				local C = dat.C
-				local key = tostring(tostring(L) .. tostring(C))	-- make name key
+				local key = tostring(tostring(dat.L) .. tostring(dat.C))	-- make name key
 				local dname = pub_names[key]
 					if dname == nil then
-				dname = "key " .. key .." not found"
+				dname = "key " .. key .." not found in pub_names"
 				end
-				me.Pub_box:setcell(L,C,dname)
+				me.Pub_box:setcell(dat.L,dat.C,dname)
 		end

-		me.Pub_box.Redraw= "ALL"
+	--	me.Pub_box.Redraw= "ALL"

 			-- Create Trials Achievements Box==========================
 		me.Trials_box= iup.matrix {numcol=1, numcol_visible=1,  numlin=4, widthdef=110}
@@ -984,13 +988,14 @@ end

 		iup.Append(accounts[acc].char_tabs,me.tab)

-		local panel =((#accounts[acc].playerIDs * 100)+120)
-		if panel < 680  then
-			panel = 680
-		elseif panel >950 then
+		local wide =(((#accounts[acc].playerIDs+1) * 110)+10)
+		if wide < 680  then
+			wide = 680
+		elseif wide >950 then
 		--	panel = 1600
 		end
-		accounts[acc].panelsize =  tostring(panel) ..  "x300"
+
+		accounts[acc].panelsize =  tostring(wide) ..  "x310"
 	end  -- Chars

 -- Add to end of Characters
@@ -1020,7 +1025,7 @@ iup.Append(accounts[acc].char_tabs, accounts[acc].log_tab)
 	for line,key in ipairs(Pub_Dat.key) do		-- over each dungeon
 	    -- does that char exist in the table.
 		for col,playerID in ipairs(accounts[acc].playerIDs) do	-- over each char in order
-			if dung.pub.key[key][playerID] == nil then
+			if dung.pub.key[key][playerID] ~= true then
 				dung.pub.box:setcell(line,col, "N")
 				iup.SetAttribute(dung.pub.box,"BGCOLOR" .. tostring(line) .. ":" .. tostring(col), BG_Colour_Not_Complete)
 			else
@@ -1031,32 +1036,31 @@ iup.Append(accounts[acc].char_tabs, accounts[acc].log_tab)
 	end
 	-- Create Pub Dungeon Tab ==================================

-	dung.Pub_tab = iup.vbox {
+	dung.pub.tab = iup.vbox {
 						["tabtitle"] =L.Pub,
 						dung.pub.box,
 						iup.fill{},
 				}

-	iup.Append(accounts[acc].dung_tabs, dung.Pub_tab)
+	iup.Append(accounts[acc].dung_tabs, dung.pub.tab)


 	-- Grp Dungeons  ===========================================
 	for _,i in ipairs (Grp_Order) do
 		iup.Append(accounts[acc].dung_tabs, dung.Grp[i].tab)
-
 		-- Populate with character data ============================
-		for line,key in ipairs(dung.Grp[i].key) do		-- over each dungeon
-			-- does that char exist in the table.
+		for line, key in ipairs(Grp_Dat[i].key) do  -- for lines going down, get the key
+		-- does that char exist in the table. Check by PlayerID
 			for col,playerID in ipairs(accounts[acc].playerIDs) do	-- over each char in order
-				if dung.Grp[i].key[key][playerID] == nil then
-					dung.Grp[i].box:setcell(line,col, "N")
-					iup.SetAttribute(dung.Grp[i].box,"BGCOLOR" .. tostring(line) .. ":" .. tostring(col), BG_Colour_Not_Complete)
-				else
+				if dung.Grp[i].key[key][playerID]  then
 					dung.Grp[i].box:setcell(line,col, "Y")
 					iup.SetAttribute(dung.Grp[i].box,"BGCOLOR" .. tostring(line) .. ":" .. tostring(col), BG_Colour_Complete)
+				else
+					dung.Grp[i].box:setcell(line,col, "N")
+					iup.SetAttribute(dung.Grp[i].box,"BGCOLOR" .. tostring(line) .. ":" .. tostring(col), BG_Colour_Not_Complete)
 				end
 			end
-	end
+		end
 	end

 	-- Create DLC Dungeon Character Box=========================
diff --git a/data/Group1.lua b/data/Group1.lua
index 6e32a33..d36624f 100644
--- a/data/Group1.lua
+++ b/data/Group1.lua
@@ -1,7 +1,7 @@
 --Mode 1 Data  N, V, VH

 -- key is Achievement ID, L,C are Line Column in Grid
-Grp_Dat["1N"].dat = {
+Grp_Dat["1N"].id = {
 [294]= {L=1, C=1},		-- "Fungal Grotto I Vanquisher",
 [78]= {L=2, C=1},		-- "Darkshade Caverns I Vanquisher"
 [272]= {L=3, C=1},		-- "Arx Corinium Vanquisher"
@@ -26,7 +26,7 @@ Grp_Dat["1N"].vet = false
 Grp_Dat["1N"].key=grp1tokey	-- from keys.lua file


-Grp_Dat["1V"].dat = {
+Grp_Dat["1V"].id = {
 [1556]= {L=1, C=1},		-- "Fungal Grotto I Conqueror"
 [1581]= {L=2, C=1},		-- "Darkshade Caverns I Conqueror"
 [1604]= {L=3, C=1},		-- "Arx Corinium Conqueror"
@@ -51,7 +51,7 @@ Grp_Dat["1V"].vet = true
 Grp_Dat["1V"].key=grp1tokey	-- from keys.lua file

 --Hard Mode
-Grp_Dat["1VH"].dat = {
+Grp_Dat["1VH"].id = {
 [1561]= {L=1, C=1},		-- "Catch of the Day"
 [1585]= {L=2, C=1},		-- "Well Out of Warranty"
 [1608]= {L=3, C=1},		-- "Snake Skinner"
diff --git a/data/Group2.lua b/data/Group2.lua
index 3b45e1c..ec0d199 100644
--- a/data/Group2.lua
+++ b/data/Group2.lua
@@ -3,7 +3,7 @@
 -- key is Achievement ID, L,C are Line Column in Grid
 -- Not all dungeons have second mode

-Grp_Dat["2N"].dat = {
+Grp_Dat["2N"].id = {
 [1562]= {L=1, C=1},		-- "Fungal Grotto II Vanquisher"
 [1587]= {L=2, C=1},		-- "Darkshade Caverns II Vanquisher"
 --[272]= {L=3, C=1},		-- "Arx Corinium Vanquisher"
@@ -27,7 +27,7 @@ Grp_Dat["2N"].dat = {
 Grp_Dat["2N"].vet = false
 Grp_Dat["2N"].key=grp2tokey	-- from keys.lua file

-Grp_Dat["2V"].dat = {
+Grp_Dat["2V"].id = {
 [343]= {L=1, C=1},		-- "Fungal Grotto II Conqueror"
 [464]= {L=2, C=1},		-- "Darkshade Caverns II Conqueror"
 --[272]= {L=3, C=1},		-- "Arx Corinium Vanquisher"
@@ -52,7 +52,7 @@ Grp_Dat["2V"].vet = true
 Grp_Dat["2V"].key=grp2tokey	-- from keys.lua file

 -- Hard Mode Activated
-Grp_Dat["2VH"].dat = {
+Grp_Dat["2VH"].id = {
 [324]= {L=1, C=1},		-- "Fearless Assaulter"
 [467]= {L=2, C=1},		-- "Deadly Engineer"
 -- 272]= {L=3, C=1},		-- "Arx Corinium Vanquisher"