Added Death/Map History

His Dad [04-20-15 - 04:52]
Added Death/Map History
Filename
history.lua
diff --git a/history.lua b/history.lua
index b2aadef..20542e5 100644
--- a/history.lua
+++ b/history.lua
@@ -11,7 +11,13 @@ hist = {
 	debug = false
 }

-
+local function log_truncate(max)
+--Limit log to max
+	for i = max, #hist.SV.log  do
+		table.remove(hist.SV.log)
+		d("Truncated log.  Size now" .. tostring(hist.SV.log))
+	end
+end

 local function log(text)

@@ -91,6 +97,9 @@ end

 local function Activated()
 	hist.me.levels[hist.me.level].time = math.floor(GetSecondsPlayed() /60)
+	log("Activated")
+	log_truncate(5)
+
 end


@@ -150,7 +159,17 @@ local function setup_char()
 end

 local function Dead()
+	-- Per Level
 	hist.me.levels[hist.me.level].deaths = hist.me.levels[hist.me.level].deaths +1
+	-- Per Map
+	local map = GetMapName()
+	if hist.me.map[map] == nil then
+		hist.me.map[map] = {}
+	end
+	if hist.me.map[map].deaths == nil then
+		hist.me.map[map].deaths = 0
+	end
+	hist.me.map[map].deaths = hist.me.map[map].deaths +1
 end
 function hist.Initialise(_, addOnName)
 	if (hist.name ~= addOnName) then return end
@@ -181,6 +200,11 @@ function hist.Initialise(_, addOnName)
 		hist.SV.old = {}
 		log("hist.SV.old  created")
 	end
+
+	if hist.me.map == nil then
+			hist.me.map = {}
+	end
+
 	if hist.SV.data[hist.player] == nil
 	then
 		setup_char()