-
Notifications
You must be signed in to change notification settings - Fork 49
/
Copy pathutils.lua
51 lines (35 loc) · 1.14 KB
/
utils.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
HonorSpyUtils = {}
function HonorSpyUtils:getFullUnitName(unit)
if (unit == "player") then
return UnitName("player") .. "-" .. GetRealmName()
end
local name, realm = UnitFullName(unit)
if (name == nil) then
return nil
end
if (realm == nil) then
realm = GetRealmName()
end
realm = realm:gsub(" ", "")
return name .. "-" .. realm, name, realm
end
function HonorSpyUtils:getDisplayName(playerName)
local name, realm = HonorSpyUtils:splitNameAndServer(playerName)
if (realm == (GetRealmName():gsub(" ", "")) or realm == nil) then
return name
end
return playerName
end
function HonorSpyUtils:getRealmFromFullUnitName(playerName)
return select(2, HonorSpyUtils:splitNameAndServer(playerName))
end
function HonorSpyUtils:getCompleteName(playerName)
local name, realm = HonorSpyUtils:splitNameAndServer(playerName)
if (realm == nil) then
return name .. '-' .. GetRealmName()
end
return playerName
end
function HonorSpyUtils:splitNameAndServer(playerName)
return strsplit('-', playerName)
end