1
0
Bifurcation 0
Ce dépôt a été archivé le 2020-03-15. Vous pouvez voir ses fichiers ou le cloner, mais pas ouvrir de ticket ou de demandes d'ajout, ni soumettre de changements.
questhelperredux/QHCollector/collect_util.lua
Nathanial.C.Jones 5287a36af4 Working on separating the collector subsystem out from the rest of the system. Initially it will be a required dependency.
Please note that though these files have been added, nothing has changed yet in the main system to support this separation... i.e. no files have been removed and no files have been changed in the main system for this.
2012-01-01 20:46:45 +00:00

53 lignes
2,3 Kio
Lua

local GetTime = QuestHelperCollector_GetTime
QuestHelper_File["collect_util.lua"] = "4.0.1.$svnversion$"
QuestHelper_Loadtime["collect_util.lua"] = GetTime()
local function IsMonsterGUID(guid)
QuestHelper: Assert(strlen(guid) == 18, "guid len " .. guid) -- 64 bits, plus the 0x prefix
QuestHelper: Assert(guid:sub(1, 2) == "0x", "guid 0x-prefix " .. guid)
return guid:sub(5, 5) == "3" or guid:sub(5, 5) == "5"
end
local function GetMonsterUID(guid)
QuestHelper: Assert(strlen(guid) == 18, "guid len " .. guid) -- 64 bits, plus the 0x prefix
QuestHelper: Assert(guid:sub(1, 2) == "0x", "guid 0x-prefix " .. guid)
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.
return guid:sub(9, 18) -- here's our actual identifier
end
local function GetMonsterType(guid)
QuestHelper: Assert(strlen(guid) == 18, "guid len " .. guid) -- 64 bits, plus the 0x prefix
QuestHelper: Assert(guid:sub(1, 2) == "0x", "guid 0x-prefix " .. guid)
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.
if GetBuildInfo():sub(1, 3) == "3.2" then
return tonumber(guid:sub(9, 12), 16) -- here's our actual identifier
else
return tonumber(guid:sub(7, 10), 16) -- 3.3 and in the future, including 0.3.0
end
end
local function GetItemType(link, vague)
QuestHelper:Assert(link, "Item did not have a link! Say WHAT?")
local result = tonumber(string.match(link,
(vague and "" or "^") .. "|cff%x%x%x%x%x%x|Hitem:(%d+):[%d:-]+|h%[[^%]]*%]|h|r".. (vague and "" or "$")
))
QuestHelper:Assert(result, "Item does not have a type ('" .. link .. "')")
return result
end
local function GetQuestType(link)
return tonumber(string.match(link,
"^|cff%x%x%x%x%x%x|Hquest:(%d+):[%d-]+|h%[[^%]]*%]|h|r$"
)), tonumber(string.match(link,
"^|cff%x%x%x%x%x%x|Hquest:%d+:([%d-]+)|h%[[^%]]*%]|h|r$"
))
end
function QH_Collect_Util_Init(_, API)
API.Utility_IsMonsterGUID = IsMonsterGUID
API.Utility_GetMonsterUID = GetMonsterUID
API.Utility_GetMonsterType = GetMonsterType
API.Utility_GetItemType = GetItemType
API.Utility_GetQuestType = GetQuestType
end