All checks were successful
forgejo/Czech Quests/addon/pipeline/head This commit looks good
34 lines
No EOL
780 B
Lua
Executable file
34 lines
No EOL
780 B
Lua
Executable file
local _, addon = ...
|
|
|
|
local function BuildIndex(text)
|
|
local numberMarks = text:gsub("%d+%.?%d*", "#?")
|
|
local normalized = numberMarks:gsub('"', "'")
|
|
return normalized
|
|
end
|
|
|
|
local function FillPlaceholders(text)
|
|
if text == nil then
|
|
return text
|
|
end
|
|
|
|
local playerName = UnitName("player")
|
|
|
|
local formatted = text;
|
|
formatted = string.gsub(formatted, '<name>', playerName);
|
|
|
|
return formatted
|
|
end
|
|
|
|
local function GetSpeech(message)
|
|
local index = BuildIndex(message)
|
|
local speech = addon.data.speech[index];
|
|
local text = speech and speech.m or nil
|
|
if text then
|
|
return FillPlaceholders(
|
|
addon.API.FillNumbers(text, message)
|
|
)
|
|
else
|
|
return nil
|
|
end
|
|
end
|
|
addon.API.GetSpeech = GetSpeech |