-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSFUtils_Guild.lua
More file actions
61 lines (49 loc) · 1.35 KB
/
SFUtils_Guild.lua
File metadata and controls
61 lines (49 loc) · 1.35 KB
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
52
53
54
55
56
57
58
59
60
local sfutil = LibSFUtils
-- ------------------------------------------------------
-- Guild helper functions
-- SafeGetGuildName(index)
-- where index is 1..5
--
-- returns: guild name, guild Id
-- or "Invalid guild x", nil if no such guild
--
-- does not return nil for name! - if bad then return nil for guildId
function sfutil.SafeGetGuildName(index)
-- Guildname
local guildId = GetGuildId(index)
if not guildId then
return ("Invalid guild " .. index),nil
end
local guildName = GetGuildName(guildId)
-- Occurs sometimes
if(not guildName or (guildName):len() < 1) then
guildName = "Guild " .. guildId
end
return guildName, guildId
end
-- Get list of all active guild names in index order (1..5)
function sfutil.GetActiveGuildNames()
local guildList = {}
local numGuilds = GetNumGuilds()
if numGuilds > 0 then
local name, id
for guild = 1, numGuilds do
name, id = sfutil.SafeGetGuildName(guild)
table.insert(guildList, name)
end
end
return guildList
end
-- Get list of all active guild ids in index order (1..5)
function sfutil.GetActiveGuildIds()
local guildList = {}
local numGuilds = GetNumGuilds()
if numGuilds > 0 then
local name, id
for guild = 1, numGuilds do
name, id = sfutil.SafeGetGuildName(guild)
table.insert(guildList, id)
end
end
return guildList
end