1 QuestHelper_File
["collect_util.lua"] = "Development Version"
2 QuestHelper_Loadtime
["collect_util.lua"] = GetTime()
4 local function IsMonsterGUID(guid
)
5 QuestHelper
: Assert(#guid
== 18, "guid len " .. guid
) -- 64 bits, plus the 0x prefix
6 QuestHelper
: Assert(guid
:sub(1, 2) == "0x", "guid 0x-prefix " .. guid
)
7 return guid
:sub(5, 5) == "3" or guid
:sub(5, 5) == "5"
10 local function GetMonsterUID(guid
)
11 QuestHelper
: Assert(#guid
== 18, "guid len " .. guid
) -- 64 bits, plus the 0x prefix
12 QuestHelper
: Assert(guid
:sub(1, 2) == "0x", "guid 0x-prefix " .. guid
)
13 QuestHelper
: Assert(guid
:sub(5, 5) == "3" or guid
:sub(5, 5) == "5", "guid 3-prefix " .. guid
) -- It *shouldn't* be a player or a pet by the time we've gotten here. If so, something's gone wrong.
14 return guid
:sub(9, 18) -- here's our actual identifier
17 local function GetMonsterType(guid
)
18 QuestHelper
: Assert(#guid
== 18, "guid len " .. guid
) -- 64 bits, plus the 0x prefix
19 QuestHelper
: Assert(guid
:sub(1, 2) == "0x", "guid 0x-prefix " .. guid
)
20 QuestHelper
: Assert(guid
:sub(5, 5) == "3" or guid
:sub(5, 5) == "5", "guid 3-prefix " .. guid
) -- It *shouldn't* be a player or a pet by the time we've gotten here. If so, something's gone wrong.
21 if GetBuildInfo():sub(1, 3) == "3.2" then
22 return tonumber(guid
:sub(9, 12), 16) -- here's our actual identifier
24 return tonumber(guid
:sub(7, 10), 16) -- 3.3 and in the future, including 0.3.0
28 local function GetItemType(link
, vague
)
29 return tonumber(string.match(link
,
30 (vague
and "" or "^") .. "|cff%x%x%x%x%x%x|Hitem:(%d+):[%d:-]+|h%[[^%]]*%]|h|r".. (vague
and "" or "$")
34 local function GetQuestType(link
)
35 return tonumber(string.match(link
,
36 "^|cff%x%x%x%x%x%x|Hquest:(%d+):[%d-]+|h%[[^%]]*%]|h|r$"
37 )), tonumber(string.match(link
,
38 "^|cff%x%x%x%x%x%x|Hquest:%d+:([%d-]+)|h%[[^%]]*%]|h|r$"
42 function QH_Collect_Util_Init(_
, API
)
43 API
.Utility_IsMonsterGUID
= IsMonsterGUID
44 API
.Utility_GetMonsterUID
= GetMonsterUID
45 API
.Utility_GetMonsterType
= GetMonsterType
46 API
.Utility_GetItemType
= GetItemType
47 API
.Utility_GetQuestType
= GetQuestType