1
0
Bifurcation 0

Started "flattening" the collection, which will ultimately make it easier to import into a database. WOOHOO!

Basically, all lua tables will have keys that are equal to their DB table names and their data will have a key that contains the row data in a tab delimited format.

Note: This is still a work in progress and some things need to be revisited... i.e. collect_merchant.lua, since we want to extract the currency id from the currency link... no documentation is thus far found for what the type part of a currency link is, so we're going to collect a little data and see.
Cette révision appartient à :
Nathanial.C.Jones 2013-01-31 03:19:54 +00:00
Parent d3e9acc290
révision b50a530943
3 fichiers modifiés avec 69 ajouts et 42 suppressions

Voir le fichier

@ -99,11 +99,13 @@ function QH_Collector_SetupData()
end
local realm = GetRealmName()
local sessiontime = time()
if not QuestHelper_Collector.created then
QuestHelper_Collector.created = time();
QuestHelper_Collector.created = sessiontime;
end
local session = string.format("%q\t%q\t%q\t%q\t%q", svnversion, realm, buildInfo, locale, altfaction)
local session = string.format("%s\t%s\t%s\t%s\t%s", svnversion, realm, buildInfo, locale, altfaction)
if not QuestHelper_Collector.sessions then QuestHelper_Collector.sessions = {} end

Voir le fichier

@ -18,42 +18,53 @@ local GetItemType
local function AddChatType(typ)
local target = UnitGUID("target")
if not target then return end
if not IsMonsterGUID(target) then return end
target = GetMonsterType(target)
if not QHCM[target] then QHCM[target] = {} end
QHCM[target]["chat_" .. typ] = (QHCM[target]["chat_" .. typ] or 0) + 1
return QHCM[target]
local ret = {}
ret.base_info = string.format("%d\t%s", target, typ)
table.insert(QHCM, ret)
return ret
end
local function MerchantShow()
local ct = GetMerchantNumItems()
for i = 1, ct do if not GetMerchantItemLink(i) then return end end -- We want to make sure it's cached, otherwise we'll return wonky data. Technically this biases things away from "yes he's a shopkeeper", but honestly, it doesn't matter that much.
targ = AddChatType("shop")
if not targ then return end -- welllllp
local ct = GetMerchantNumItems()
--QuestHelper:TextOut(string.format("nitems %d", ct))
for i = 1, ct do
local itemid = GetMerchantItemLink(i)
QuestHelper: Assert(itemid)
itemid = GetItemType(itemid)
local _, _, price, quant, avail, _, _ = GetMerchantItemInfo(i)
local dstr = {}
dstr.quant = quant
dstr.avail = avail
dstr.price = price
local _, _, price, quant, avail, _, ext_cost = GetMerchantItemInfo(i)
local shop_item = {}
shop_item.base_info = string.format("%d\t%d\t%d\t%d", itemid, quant, avail, price)
if ext_cost then
ext_costs = {}
for curr = 1, GetMerchantItemCostInfo(i) do
local tex, val, link, name = GetMerchantItemCostItem(i, curr)
local ext_cost_detail = {}
ext_cost_detail.base_info = string.format("%s\t%d", name, val)
ext_cost_detail.link = link
ext_cost_detail.texture = tex
table.insert(ext_costs, ext_cost_detail)
end
shop_item.ext_costs = ext_costs
end
--if debug_output then QuestHelper:TextOut(dstr) end
if not targ.shop then targ.shop = {} end
if not targ.shop[itemid] then
targ.shop[itemid] = dstr
end
targ.shop[itemid].count = (targ.shop[itemid].count or 0) + 1
table.insert(targ.shop, shop_item)
end
end
@ -67,13 +78,13 @@ end
function QH_Collect_Merchant_Init(QHCData, API)
if not QHCData.monster then QHCData.monster = {} end
QHCM = QHCData.monster
if not QHCData.merchant then QHCData.merchant = {} end
QHCM = QHCData.merchant
QH_Event("MERCHANT_SHOW", MerchantShow)
QH_Event("GOSSIP_SHOW", GossipShow)
QH_Event("QUEST_GREETING", QuestGreeting)
IsMonsterGUID = API.Utility_IsMonsterGUID
GetMonsterType = API.Utility_GetMonsterType
GetItemType = API.Utility_GetItemType

Voir le fichier

@ -49,31 +49,39 @@ local function MouseoverUnit()
logon = nil
drunk_logon = false
end
-- First off, we see if it's "interesting".
-- The original code for this filtered out critters. I don't, because critters are cute, and rare.
if UnitExists("mouseover") and UnitIsVisible("mouseover") and not UnitIsPlayer("mouseover") and not UnitPlayerControlled("mouseover") then
local guid = UnitGUID("mouseover")
if not IsMonsterGUID(guid) then return end -- pet that isn't controlled by a player? NPC pet? It's kind of unclear, but I'm getting some, so, FIXED
local creatureid = GetMonsterUID(guid)
if not recentlySeenCritters[creatureid] then
recentlySeenCritters_Recent[creatureid] = true
recentlySeenCritters[creatureid] = true
-- register the critter here
local cid = GetMonsterType(guid)
if not QHCM[cid] then QHCM[cid] = {} end
local critter = QHCM[cid]
if cid < 30621 or cid > 30625 then AccumulateFrequency(critter, "name", UnitName("mouseover")) end -- The exceptions are for Herald Volasj's minions, which are named after your partymembers.
AccumulateFrequency(critter, "reaction", UnitReaction("mouseover", "player"))
--if not QHCM[cid] then QHCM[cid] = {} end
--local critter = QHCM[cid]
local critter = {}
critter.id = cid
if cid < 30621 or cid > 30625 then
--AccumulateFrequency(critter, "name", UnitName("mouseover")) -- The exceptions are for Herald Volasj's minions, which are named after your partymembers.
critter.name = UnitName("mouseover")
end
--AccumulateFrequency(critter, "reaction", UnitReaction("mouseover", "player"))
critter.reaction = UnitReaction("mouseover", "player")
if not drunk_logon and not drunk_message then
AccumulateFrequency(critter, "level", UnitLevel("mouseover"))
--AccumulateFrequency(critter, "level", UnitLevel("mouseover"))
critter.level = UnitLevel("mouseover")
end
local minrange = InteractDistances[1]
local maxrange = 255
-- Now we try to derive a bound for how far away it is
@ -85,19 +93,25 @@ local function MouseoverUnit()
end
end
QuestHelper: Assert(minrange >= 0 and minrange < 256 and maxrange >= 0 and maxrange < 256)
critter.loc = GetLoc()
critter.minrange = minrange
critter.maxrange = maxrange
table.insert(QHCM, critter)
--[[
local data = {}
data.loc = GetLoc()
data.minrange = minrange
data.maxrange = maxrange
if not critter.encounters then critter.encounters = {} end
table.insert(critter.encounters, data)
]]
--Merger.Add(critter, string.format("(%s %s %s),", GetLoc(), tostring(minrange), tostring(maxrange))) --strchar(minrange, maxrange))
if #recentlySeenCritters_Recent >= 100 then
for k, v in recentlySeenCritters_NextTrash do
recentlySeenCritters[v] = nil
end
recentlySeenCritters_NextTrash = recentlySeenCritters_Recent
recentlySeenCritters_Recent = {} -- BAM, garbage collection!
end
@ -115,10 +129,10 @@ function QH_Collect_Monster_Init(QHCData, API)
QH_Event("UPDATE_MOUSEOVER_UNIT", MouseoverUnit)
QH_Event("CHAT_MSG_SYSTEM", SystemMessage)
Patterns = API.Patterns
QuestHelper: Assert(Patterns)
API.Patterns_Register("DRUNK_MESSAGE_SELF1", "|c.*|r")
API.Patterns_Register("DRUNK_MESSAGE_SELF2", "|c.*|r")
API.Patterns_Register("DRUNK_MESSAGE_SELF3", "|c.*|r")
@ -130,10 +144,10 @@ function QH_Collect_Monster_Init(QHCData, API)
GetLoc = API.Callback_LocationBolusCurrent
QuestHelper: Assert(GetLoc)
Merger = API.Utility_Merger
QuestHelper: Assert(Merger)
IsMonsterGUID = API.Utility_IsMonsterGUID
GetMonsterUID = API.Utility_GetMonsterUID
GetMonsterType = API.Utility_GetMonsterType