Mercurial > wow > wowdb-profiler
changeset 96:e378295b2d6f
Handle keyword substitutions in NPC quotes for Race and Class.
author | James D. Callahan III <jcallahan@curse.com> |
---|---|
date | Thu, 30 Aug 2012 14:23:54 -0500 |
parents | c4172766561f |
children | f6369b88454f |
files | Main.lua |
diffstat | 1 files changed, 17 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/Main.lua Wed Aug 29 15:24:29 2012 -0500 +++ b/Main.lua Thu Aug 30 14:23:54 2012 -0500 @@ -632,10 +632,23 @@ do - local function ReplaceName(text) - if text == PLAYER_NAME then - return "<name>" + local KEYWORD_SUBSTITUTIONS = { + class = PLAYER_CLASS, + name = PLAYER_NAME, + race = PLAYER_RACE, + } + + + local function ReplaceKeywords(text) + if not text or text == "" then + return "" end + + for category, lookup in pairs(KEYWORD_SUBSTITUTIONS) do + local category_format = ("<%s>"):format(category) + text = text:gsub(lookup, category_format):gsub(lookup:lower(), category_format) + end + return text end @@ -646,7 +659,7 @@ local npc = NPCEntry(name_to_id_map[source_name]) npc.quotes = npc.quotes or {} npc.quotes[event_name] = npc.quotes[event_name] or {} - npc.quotes[event_name][message:gsub("(%w+)", ReplaceName)] = true + npc.quotes[event_name][ReplaceKeywords(message)] = true end end -- do-block