Refactor whole addon to follow best practices
This commit is contained in:
parent
43fc252902
commit
414aef6924
31 changed files with 7843 additions and 29579 deletions
23
Addon/Code/SpeechDataApi.lua
Executable file
23
Addon/Code/SpeechDataApi.lua
Executable file
|
@ -0,0 +1,23 @@
|
|||
local _, addon = ...
|
||||
|
||||
local function FillPlaceholders(text)
|
||||
if text == nil then
|
||||
return text
|
||||
end
|
||||
|
||||
local playerName = UnitName("player")
|
||||
|
||||
local formatted = text;
|
||||
formatted = string.gsub(formatted, '<name>', playerName);
|
||||
formatted = string.gsub(formatted, 'Champions', playerName);
|
||||
formatted = string.gsub(formatted, 'champions', playerName);
|
||||
|
||||
return formatted
|
||||
end
|
||||
|
||||
local function GetSpeech(message)
|
||||
local speech = addon.data.speech[message];
|
||||
local text = speech and speech.text or nil
|
||||
return FillPlaceholders(text)
|
||||
end
|
||||
addon.API.GetSpeech = GetSpeech
|
Loading…
Add table
Add a link
Reference in a new issue