From 5823111530ec16d799184309f96bc0b563ab78d7 Mon Sep 17 00:00:00 2001
From: dg <dg@51575b47-30f0-44d4-a5cc-537603b46e54>
Date: Mon, 16 May 2011 08:43:29 +0000
Subject: [PATCH] Found lore is now also saved in the player's profile, for
 later use

git-svn-id: http://svn.net-core.org/repos/t-engine4@3383 51575b47-30f0-44d4-a5cc-537603b46e54
---
 game/modules/tome/class/interface/PlayerLore.lua  | 1 +
 game/modules/tome/class/interface/PlayerStats.lua | 8 ++++++++
 game/modules/tome/init.lua                        | 2 +-
 3 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/game/modules/tome/class/interface/PlayerLore.lua b/game/modules/tome/class/interface/PlayerLore.lua
index 1d33f27475..45d3ebfb1c 100644
--- a/game/modules/tome/class/interface/PlayerLore.lua
+++ b/game/modules/tome/class/interface/PlayerLore.lua
@@ -85,6 +85,7 @@ function _M:learnLore(lore)
 	end
 
 	self.lore_known[lore] = true
+	if not self.additional_lore[lore] and self.registerLoreFound then self:registerLoreFound(lore) end
 	print("[LORE] learnt", lore)
 	if learnt then if l.on_learn then l.on_learn(self) end end
 end
diff --git a/game/modules/tome/class/interface/PlayerStats.lua b/game/modules/tome/class/interface/PlayerStats.lua
index 8f1c595827..e96f801477 100644
--- a/game/modules/tome/class/interface/PlayerStats.lua
+++ b/game/modules/tome/class/interface/PlayerStats.lua
@@ -66,3 +66,11 @@ function _M:registerCharacterPlayed()
 	profile.mod.characters.characters[pid] = (profile.mod.characters.characters[pid] or 0) + 1
 	profile:saveModuleProfile("characters", profile.mod.characters)
 end
+
+function _M:registerLoreFound(lore)
+	local pid = self:playerStatGetCharacterIdentifier(game.party:findMember{main=true})
+
+	profile.mod.lore = profile.mod.lore or { lore={} }
+	profile.mod.lore.lore[lore] = true
+	profile:saveModuleProfile("lore", profile.mod.lore)
+end
diff --git a/game/modules/tome/init.lua b/game/modules/tome/init.lua
index 6272186e2f..21620744e8 100644
--- a/game/modules/tome/init.lua
+++ b/game/modules/tome/init.lua
@@ -45,5 +45,5 @@ Still, this is a golden age. Civilisations are healing the wounds of thousands o
 You are an adventurer, set out to discover wonders, explore old places, and venture into the unknown for wealth and glory.
 ]]
 starter = "mod.load"
-profile_stats_fields = {"artifacts", "characters", "deaths", "uniques"}
+profile_stats_fields = {"artifacts", "characters", "deaths", "uniques", "lore"}
 allow_userchat = true
-- 
GitLab