pre 70

His Dad [08-17-20 - 21:00]
pre 70

Signed-off-by: His Dad <John@hisdad.org>
Filename
Delete-Account.lua
Delete-Character.lua
Doc/Changelog.txt
Doc/Deleteing_Characters.txt
Doc/Deleting_Accounts.txt
HistOffline.lua
data/utility.lua
history.lua
diff --git a/Delete-Account.lua b/Delete-Account.lua
index 2f77cbb..1e44d8d 100644
--- a/Delete-Account.lua
+++ b/Delete-Account.lua
@@ -14,7 +14,7 @@ local dateformat = "%Y-%m-%d, %H:%M"
 local dateformat_log = "%Y-%m-%d-%H-%M-%S"

 -- ========================
-version= "38"
+version= "70"
 require( "iuplua" )
 require( "iupluacontrols" )
 iup.SetGlobal("UTF8MODE","YES")
@@ -75,12 +75,14 @@ if lang == nil then
 lang = "en"
 end

-local path = "./data/" .. lang .. ".lua"
+-- Localisations
+local path = "./data/" .. lang .. "/" .. lang .. ".lua"
 dofile (path)




+
 function select_account()
 	local selected
 		if naccounts >1 then
diff --git a/Delete-Character.lua b/Delete-Character.lua
index 1b0430d..1c0f5b5 100644
--- a/Delete-Character.lua
+++ b/Delete-Character.lua
@@ -16,7 +16,7 @@ local dateformat = "%Y-%m-%d, %H:%M"
 local dateformat_log = "%Y-%m-%d-%H-%M-%S"

 -- ========================
-version= "22"
+version= "70"
 require( "iuplua" )
 require( "iupluacontrols" )
 iup.SetGlobal("UTF8MODE","YES")
@@ -124,20 +124,50 @@ playerName2ID={}


 for playerID, j in pairs(History_SV["Default"][account]["$AccountWide"]["data"]) do
-  if j.name == nil then
-	table.insert(playerNames, playerID)   -- old Style
-	playerName2ID[playerID] = playerID
-  else
-	table.insert(playerNames, j.name)
-	playerName2ID[j.name] = playerID
-  end
+	if j.name == nil then
+	-- old Style
+		name =  playerID
+	else
+		name = j.name
+	end
+
+	name = name .. " ("
+	if j.world ~= nil then
+		name = name .. " " .. j.world
+	end
+
+
+	if j.Class ~= nil then
+		name = name .. ", " ..j.Class
+	end
+
+	if j.Race ~= nil then
+		name = name .. ", " .. j.Race
+	end
+
+
+	if j.Alliance ~= nil then
+		name = name .. ", " .. j.Alliance
+	end
+
+	if j.LoginTime ~= nil then
+		LoginTime = os.date(dateformat,j.LoginTime)
+		name = name .. " Last: " .. LoginTime
+	end
+
+	if j.logins ~= nil then
+		name = name .. ", Logins: " .. j.logins
+	end
+	name = name .. ")"
+	table.insert(playerNames, name)
+	playerName2ID[name] = playerID

 end


 -- No players.
 if #playerNames ==  0 then
-    print ("Payer names")
+    print ("No Player names")
 --	iup.Close()
 --	os.exit()
 end
diff --git a/Doc/Changelog.txt b/Doc/Changelog.txt
index acbd14d..c560167 100644
--- a/Doc/Changelog.txt
+++ b/Doc/Changelog.txt
@@ -1,5 +1,10 @@
 2020-08  Version 70
-Southern Elsweyr Skill Quests  (Dragonhold)
+==Known not to work with IUP-Lua 5.4===
+Southern Elsweyr Skill Quests  (Dragonhold)  The "Reformation" quest is not available. Case opened with Zos
+
+Update of the Account and Character Delete Scripts
+Character Delete now gives more information to distinguish between identically named characters.
+

 2020-08-14 Version 69
 Wasn't recording the DLC Grp events correctly.
diff --git a/Doc/Deleteing_Characters.txt b/Doc/Deleteing_Characters.txt
new file mode 100644
index 0000000..5737f4a
--- /dev/null
+++ b/Doc/Deleteing_Characters.txt
@@ -0,0 +1,26 @@
+Characters come and go, but History remembers them.
+Until there are too many and it locks up.
+
+Solution:
+Delete your old scrap characters.
+
+Go to the savedvariables folder and copy the history.lua file somewhere safe.
+The script makes a backup into a subfolder History_bak. You can totally trust that, Right?!  Nope.
+
+
+Start the iuplua53.exe  console
+Use the "Load" button, navigate to the history folder and select  Delete-Character.lua
+Click Execute.
+
+If there is more than one account in use, select the account.
+
+Make the dialog wider, because I can't be arsed figuring out how to do it under program control.
+
+Select a Character to be deleted.
+Confirm.
+
+Click "Execute" again to delete another char and repeat.
+
+Close the iuplua console when finished.
+
+
diff --git a/Doc/Deleting_Accounts.txt b/Doc/Deleting_Accounts.txt
new file mode 100644
index 0000000..f2ab129
--- /dev/null
+++ b/Doc/Deleting_Accounts.txt
@@ -0,0 +1,21 @@
+You may have used an old account on your machine and now wish to remove it from History.
+
+Accounts take up display resources even if you don't select them.
+
+
+Solution:
+Delete your old accounts.
+
+Go to the savedvariables folder and copy the history.lua file somewhere safe.
+The script makes a backup into a subfolder History_bak. You can totally trust that, Right?!  Nope.
+
+
+Start the iuplua53.exe  console
+Use the "Load" button, navigate to the history folder and select  Delete-Account.lua
+Click "Execute".
+
+
+Select an Account to be deleted.
+Confirm.
+
+Close the iuplua console.
diff --git a/HistOffline.lua b/HistOffline.lua
index 0be7b55..6b70a9d 100644
--- a/HistOffline.lua
+++ b/HistOffline.lua
@@ -12,6 +12,13 @@ BG_Colour_Not_Complete = "#FFB67D"
 BG_Colour_Complete = "#A4FF5A"
 Colour_Heading_Complete = "#58FA58"
 Settings_s ="./my/visibility.lua"
+debug=false
+log = function (msg)
+	if debug then
+		print(msg)
+	end
+end
+


 --force_lang = "ru"  --	or "de" or "fr" or "ru" for debugging
@@ -28,7 +35,10 @@ if (iup._VERSION_NUMBER < 326000) then
 end

 iup.SetGlobal("UTF8MODE","YES")
+
+log("Starting to load Saved Data")
 dofile "../../SavedVariables/History.lua"
+log("Loaded.")

 Trials_Order={"Trials Norm","Trials Vet","Trials Hard"}
 Group_Dat={}
@@ -55,7 +65,7 @@ dofile "./data/Trials.lua"
 dofile "./data/Special.lua"		-- Record of non standard Achievement ID's we need to keep.
 dofile "./data/Strings.lua"		-- String Handling

-
+log("Data Files loaded Ok")

 --generate_id ()			-- Generate the file the addon uses to filter Achievement ID's
 -- This is used by the in game part history.lua to only record achievements that are used.
@@ -71,6 +81,7 @@ load_lang = function (lang)

 	local path = "./data/" .. lang .. "/"

+	log("loading lang " .. lang)
 	dofile (path .. lang .. ".lua")
 	dofile (path .. lang .."-data.lua")			--Achievement Data from game
 	lingua[lang] = {}
@@ -78,13 +89,16 @@ load_lang = function (lang)
 	lingua[lang].Area_names = Area_names		-- dofile writes to global variables
 	lingua[lang].L = L
 	lingua[lang].Ach_Detail = Ach_Detail
+
 end


+
 accounts_list = {}		-- String list for selection dialog
 playerNames = {}		-- Get name from ID.

 for acc,_ in pairs(History_SV["Default"]) do
+	log("Account: " .. acc)
 	accounts[acc] = {}
 	accounts[acc].worlds = {}
 	accounts[acc].hasblankworlds = false
@@ -115,17 +129,20 @@ for acc,_ in pairs(History_SV["Default"]) do
 		for i,j in pairs(History_SV["Default"][acc]["$AccountWide"]["worlds"]) do
 			nworlds = nworlds +1
 			table.insert(accounts[acc].worlds, i)
+			log("World " .. i)
 		end
 	end


 -- Load Character Data
+	log("Starting player Load.")
 	for playerID, _ in pairs(History_SV["Default"][acc]["$AccountWide"]["data"]) do

 		if playerID == "" then
 		print("Error: account: " .. acc .. " has blank playerID")
 		end

+		log("playerID: " .. playerID)
 		table.insert (accounts[acc].AllplayerIDs, playerID)

 		accounts[acc].player[playerID] = {}		-- stub table to hold char data, later becomes "me"
@@ -137,12 +154,14 @@ for acc,_ in pairs(History_SV["Default"]) do

 		-- Pull in some char data for processing
 		if thischar.name == nil  then --	Old Format
-	--	    print("Old Format  " .. playerID)
+			log(print("Old Format  " .. playerID))
 			me.name = playerID
 		else
 			me.name = thischar.name
 		end
 		playerNames[playerID]=me.name
+		log("playerID: " .. playerID .. " is " .. me.name)
+

 		-- == Gender
 		if thischar.Gender =="M" then
@@ -164,10 +183,12 @@ for acc,_ in pairs(History_SV["Default"]) do
 		end
 		-- == Cumulative TimePlayed
 		if thischar.timeplayed == nil then
-			me.timeplayed = math.floor(thischar.levels[level].time/60)   -- Old version compat
+			me.timeplayed =0
+			thischar.timeplayed = 0
 		else
 			me.timeplayed = math.floor(thischar.timeplayed/60)
 		end
+
 		-- world

 		if thischar.world == nil then
@@ -184,6 +205,7 @@ for acc,_ in pairs(History_SV["Default"]) do
 	table.sort(accounts[acc].playerIDs_vet,function(a,b) return (playerNames[a] < playerNames[b]) end)
 end

+
 load_visibility()


@@ -302,6 +324,7 @@ load_visibility()

   -- ================  END Accountwide Data

+	log("Account Wide for Account " .. acc .. " Done")

   --=================  START OF CHARACTER MODE DISPLAY

@@ -313,7 +336,7 @@ load_visibility()

 		thischar = History_SV["Default"][acc]["$AccountWide"]["data"][playerID]	-- shorter reference: History DB

-
+		log("Account " .. acc .. " PlayerID " .. playerID .. ", Leveling Box")
 		-- Generate the leveling box.  ============================

 		me.leveling_box = iup.matrix {numcol=6, numcol_visible=6,  widthdef=60}
@@ -424,14 +447,15 @@ load_visibility()
 -- Create WorldBoss Achievements Box==========================

 		me.WB_box= Location_Box()
-		-- print("Done WB Box")
 		Populate_Dat(me.WB_box, WB_dat,me.ach)
+		log("Done WB Box")


 -- Create SkillQuest Achievements Box==========================

 		me.SQ_box= Location_Box()
 		Populate_Dat(me.SQ_box, SQ_dat,me.ach)
+		log("Done SQ Box")

 --========== DLC

@@ -748,6 +772,7 @@ table.sort(accounts_list)

 function select_account()
 	local selected
+	local account
 		if #accounts_list > 1 then
 			selected = iup.ListDialog (1, L.SelectA,
 					#accounts_list,	--Size
@@ -759,10 +784,15 @@ function select_account()
 			if selected <0 then
 				return nil		-- Canceled				iup.SetAttribute(ADung.box,"BGCOLOR" .. "0:" .. tostring(col), BG_Colour_Not_Complete)
 			else
-				return accounts_list[selected+1]
+				account = accounts_list[selected+1]
+				log("Account " ..account .. " selected.")
+				return account
 			end
 		else
-		return accounts_list[1]		-- only 1 account, no need for Dialog
+
+		account = accounts_list[1]		-- only 1 account, no need for Dialog
+		log("Account " ..account .. " selected.")
+		return account
 		end
 end

diff --git a/data/utility.lua b/data/utility.lua
index 20e909a..666b432 100644
--- a/data/utility.lua
+++ b/data/utility.lua
@@ -117,7 +117,7 @@ end
 generate_id=function()
 --write a combined list of achievement id we look for to add to the in-game part (cut and paste) for filtering
     local unique_id= {}   -- (id,true}
-
+	print("Generating ids.lua")
 	local outfile=io.open("data/ids.lua", "w")

 	if outfile == nil then
@@ -196,6 +196,7 @@ end
 --Run through Location data to get the info needed to dimension the WB and SQ boxes
 Location_Box = function (name)

+	log("Location Box ")
 	local cols = {}
 	local lines = {}
 	local Areas = {}
diff --git a/history.lua b/history.lua
index 353a558..2831f8d 100644
--- a/history.lua
+++ b/history.lua
@@ -57,22 +57,21 @@ local function get_start ()	-- get better start date from Achievements
 		earliest_Achievement = id
 		elseif earliest_time > ach.time then
 		earliest_time = ach.time
+		end
 	end
-end

-if earliest_time == 0 then	-- No Achievements
-	earliest_time = GetTimeStamp()
-end
+	if earliest_time == 0 then	-- No Achievements
+		earliest_time = GetTimeStamp()
+	end

-if hist.me.Created == nil	then
-	hist.me.Created = earliest_time
-	elseif hist.me.Created > earliest_time then		-- Quest was earlier, then reset to earlier
-	if hist.debug then
-d("Start Time Reset for " .. hist.playerName)
-end
-	log ("Start Time Reset.")
-	hist.me.Created = earliest_time
+	if hist.me.Created == nil	then
+		hist.me.Created = earliest_time
+		if hist.debug then
+				d("Start Time Reset for " .. hist.playerName)
+		end
+		log ("Start Time Reset.")
 	end
+
 end

 local function Achievement(_, name, points, id, link)
@@ -94,8 +93,8 @@ local function Achievement(_, name, points, id, link)
 		end

 		if hist.debug then
-		d("Achievement Awarded:.. ")
-		d(hist.me.ach[id])
+			d("Achievement Awarded:.. ")
+			d(hist.me.ach[id])
 		end
 	end
 end
@@ -209,7 +208,7 @@ local function levelup(_, unitTag,_)
 	if hist.debug then
 		log("Level up to " .. hist.me.level)
 	end
-
+
 	hist.me.levels[hist.me.level] = {
 		begin = GetTimeStamp(),
 		time  = 0,		-- Accumulated time in Minutes
@@ -462,6 +461,10 @@ if (hist.name ~= addOnName) then return end
 		hist.me.IDVersion = ""
 	end

+	if hist.me.timeplayed == nil then
+		hist.me.timeplayed = 0
+	end
+
 	if hist.debug then
 		log_truncate(5000)
 	else
@@ -525,6 +528,7 @@ if (hist.name ~= addOnName) then return end
 	if (hist.SV.this_version <55) then
 		log("Erasing Achievements ready for format 55.")
 		hist.me.ach = {}
+		hist.me.craft = nil
 		hist.SV.old = nil
 		hist.SV.cleaned1 = nil
 		load_history()