Grp and Pub working

His Dad [06-25-15 - 09:55]
Grp and Pub working
Filename
HistOffline.lua
data/data.lua
diff --git a/HistOffline.lua b/HistOffline.lua
index 32caefe..5e6fff3 100644
--- a/HistOffline.lua
+++ b/HistOffline.lua
@@ -244,6 +244,29 @@ end
 								}
   accounts[acc].mode.title =  L.Mode
   accounts[acc].mode.margin = "15x5"
+
+  -- Prepare for Dungeon data recording as we iterate through characters.
+  accounts[acc].dung = {}		-- put all dungeon mode stuff here. Populate it with character data.
+  dung = accounts[acc].dung
+  dung.pub = {}
+  dung.grp = {}
+  dung.vet = {}
+  dung.trial = {}
+
+
+  -- a table for each dungeon to which we add characters
+  for _,i in ipairs(grp2key) do
+	  dung.pub[i] = {}
+	  dung.grp[i] = {}
+  end
+
+  for _,i in ipairs(trial2key) do
+	  dung.trial[i] = {}
+  end
+
+  for _,i in ipairs(vet2key) do
+	  dung.vet[i] = {}
+  end
   -- ================  END Accountwide Data

   --=================  START OF CHARACTER MODE DISPLAY
@@ -331,10 +354,13 @@ end

 		-- set text to black if achievement found.
 		for id,_ in pairs (grp_dat) do
-			local colour
+			local colour,key
 			if thischar.ach[id] ~= nil then
 				colour = "FGCOLOR" .. grp_dat[id].L .. ":" .. grp_dat[id].C
 				iup.SetAttribute(me.Grp_box, colour, Colour_Complete)
+				-- Add char to dungeon
+				key = tostring(grp_dat[id].L .. grp_dat[id].C)
+				dung.grp[key][char] = "Y"
 			end
 		end

@@ -391,6 +417,9 @@ end
 			if thischar.ach[id] ~= nil then
 				local colour = "FGCOLOR" .. pub_dat[id].L .. ":" .. pub_dat[id].C
 				iup.SetAttribute(me.Pub_box, colour, Colour_Complete)
+				-- Add char to dungeon
+				key = tostring(pub_dat[id].L .. pub_dat[id].C)
+				dung.pub[key][char] = "Y"
 			end
 		end

@@ -466,6 +495,9 @@ end
 				-- Increment count and display
 				Vet_Info[key].count = Vet_Info[key].count+1
 				me.Vet_box:setcell(L,C,dname .. " (" .. Vet_Info[key].count ..")")
+
+				-- Add char to dungeon
+			--	dung.vet[key][char] = "Y"
 			end
 		end

@@ -796,16 +828,14 @@ iup.Append(accounts[acc].char_tabs, accounts[acc].log_tab)

 --=================  END OF CHARACTER MODE DISPLAY
 --=================  START OF DUNGEON MODE DISPLAY
-	accounts[acc].dung = {}		-- put all dungeon mode stuff here
-    local dung = accounts[acc].dung

 	-- Create Pub Dungeon Character Box=========================

 	dung.Pub_box = {}
-	dung.Pub_box = iup.matrix {numcol=#accounts[acc].names,  numlin=#seq2key, widthdef=90}
+	dung.Pub_box = iup.matrix {numcol=#accounts[acc].names,  numlin=#grp2key, widthdef=90}
 	--Set Line titles
-	for i=1, #seq2key do
-		dung.Pub_box:setcell(i, 0, pub_names[seq2key[i]])
+	for i=1, #grp2key do
+		dung.Pub_box:setcell(i, 0, pub_names[grp2key[i]])
 	end
 	--set lines
 	dung.Pub_box:setcell(0,0, L.Location)
@@ -817,6 +847,18 @@ iup.Append(accounts[acc].char_tabs, accounts[acc].log_tab)

 	iup.SetAttribute(dung.Pub_box, "READONLY", "YES")

+	-- Populate with character data ============================
+	for line,key in ipairs(grp2key) do		-- over each dungeon
+	    -- does that char exist in the table.
+		for i =1, #accounts[acc].names do	-- over each char in order
+		    local char = accounts[acc].names[i]
+			if dung.pub[key][char] == nil then
+				dung.Pub_box:setcell(line,i, "N")
+			else
+				dung.Pub_box:setcell(line,i, "Y")
+			end
+		end
+	end
 	-- Create Pub Dungeon Tab ==================================

 	dung.Pub_tab = iup.vbox {
@@ -830,10 +872,10 @@ iup.Append(accounts[acc].char_tabs, accounts[acc].log_tab)
 	-- Create Grp Dungeon Character Box=========================

 	dung.Grp_box = {}
-	dung.Grp_box = iup.matrix {numcol=#accounts[acc].names,  numlin=#seq2key, widthdef=90}
+	dung.Grp_box = iup.matrix {numcol=#accounts[acc].names,  numlin=#grp2key, widthdef=90}
 	--Set Line titles
-	for i=1, #seq2key do
-		dung.Grp_box:setcell(i, 0, grp_names[seq2key[i]])
+	for i=1, #grp2key do
+		dung.Grp_box:setcell(i, 0, grp_names[grp2key[i]])
 	end
 	--set lines
 	dung.Grp_box:setcell(0,0, L.Location)
@@ -843,6 +885,21 @@ iup.Append(accounts[acc].char_tabs, accounts[acc].log_tab)
 	end

 	iup.SetAttribute(dung.Grp_box, "READONLY", "YES")
+
+	-- Populate with character data ============================
+	for line,key in ipairs(grp2key) do		-- over each dungeon
+	    -- does that char exist in the table.
+		for i =1, #accounts[acc].names do	-- over each char in order
+		    local char = accounts[acc].names[i]
+			if dung.grp[key][char] == nil then
+				dung.Grp_box:setcell(line,i, "N")
+			else
+				dung.Grp_box:setcell(line,i, "Y")
+			end
+		end
+	end
+
+	-- Create Grp Dungeon Tab ==================================
 	dung.Grp_tab = iup.vbox {
 						["tabtitle"] =L.Grp,
 						dung.Grp_box,
@@ -866,6 +923,8 @@ iup.Append(accounts[acc].char_tabs, accounts[acc].log_tab)
 	end

 	iup.SetAttribute(dung.Vet_box, "READONLY", "YES")
+
+	-- Create Vet Dungeon Tab ==================================
 	dung.Vet_tab = iup.vbox {
 						["tabtitle"] =L.Vet,
 						dung.Vet_box,
@@ -889,6 +948,8 @@ iup.Append(accounts[acc].char_tabs, accounts[acc].log_tab)
 	end

 	iup.SetAttribute(dung.Trial_box, "READONLY", "YES")
+
+	-- Create Trial Tab ============================================
 	dung.Trial_tab = iup.vbox {
 						["tabtitle"] =L.Trial,
 						dung.Trial_box,
diff --git a/data/data.lua b/data/data.lua
index b45263c..95e35cc 100644
--- a/data/data.lua
+++ b/data/data.lua
@@ -328,7 +328,7 @@ SQ_dat = {
 }

 -- Sequence to key (Pub and grp)
-seq2key = {
+grp2key = {
 --EP
 "11",
 "21",