# HG changeset patch # User John@Yosemite-PC # Date 1334517590 14400 # Node ID 6035541e47dd1df7ba25904e3dcd300c36003164 # Parent 22b37c800bc4852266e4919f4880777b2447b9aa Memorize the master looter diff -r 22b37c800bc4 -r 6035541e47dd Looting.lua --- a/Looting.lua Sun Apr 15 14:42:14 2012 -0400 +++ b/Looting.lua Sun Apr 15 15:19:50 2012 -0400 @@ -153,17 +153,49 @@ end, } + +masterLooter = nil +masterLooterIsMe = false + +function UpdateML() + local lootmethod, masterlooterPartyID, masterlooterRaidID = _G.GetLootMethod() + print("lm",lootmethod) + if lootmethod == "master" then + local oldMasterLooter + oldMasterLooter = masterLooter + masterLooterIsMe = false + if masterlooterPartyID and masterlooterPartyID > 0 then + masterLooter = _G.UnitName("party"..masterlooterPartyID) + elseif masterlooterRaidID and masterlooterRaidID > 0 then + masterLooter = _G.UnitName("raid"..masterlooterRaidID) + else + masterLooter = _G.UnitName("player") + masterLooterIsMe = true + end + print("master looter is", masterLooter) + + if masterLooter ~= oldMasterLooter then + statelistener:StateEvent() -- todo: this isn't how to fire an event! + end + else + masterLooter = nil + masterLooterIsMe = false + end +end + function InitializeLooting() event:RegisterEvent("OPEN_MASTER_LOOT_LIST",OpenMasterLootList) event:RegisterEvent("UPDATE_MASTER_LOOT_LIST",UpdateMasterLootList) event:RegisterEvent("LOOT_CLOSED",LootClosed) event:RegisterEvent("LOOT_OPENED",LootOpened) - -- todo: what are these event:RegisterEvent("LOOT_SLOT_CLEARED",function(_,index) InitiateLSClear(index) end) - event:RegisterEvent("LOOT_SLOT_CHANGED",function() print("LSChanged") end) + --event:RegisterEvent("LOOT_SLOT_CHANGED",function() print("LSChanged") end) RegisterListenerStateChange(statelistener) statelistener:StateEvent() + + UpdateML() + event:RegisterEvent("PARTY_LOOT_METHOD_CHANGED",UpdateML) end - +