# HG changeset patch # User John@Yosemite-PC # Date 1334373243 14400 # Node ID db7e4ee34dceafa4cca0313d95e75bc5ea641800 # Parent 62805e6b46c5e0f682f808e4f435251837033bff Lots of support for mobs with multiple loots diff -r 62805e6b46c5 -r db7e4ee34dce Gui.lua --- a/Gui.lua Fri Apr 13 22:09:17 2012 -0400 +++ b/Gui.lua Fri Apr 13 23:14:03 2012 -0400 @@ -215,7 +215,7 @@ ["Redraw"]= function(self) self.data = {} for i,v in pairs(stateitemlist) do - local entry = {value=i, text=v.link, link=v.link, mlid=v.mlid} + local entry = {value=i, text=v.link, link=v.link, mlid=v.mlid, disabled=v.disabled} table.insert(self.data,entry) end if self.widget then diff -r 62805e6b46c5 -r db7e4ee34dce Looting.lua --- a/Looting.lua Fri Apr 13 22:09:17 2012 -0400 +++ b/Looting.lua Fri Apr 13 23:14:03 2012 -0400 @@ -41,9 +41,13 @@ _G.LootSlot(i) end local items = {} + local threshold = _G.GetLootThreshold() + print("threshold: ", threshold) for i = 1,n do + local _,_,_,rarity,_ = _G.GetLootSlotInfo(i) + print("item: rarity: ",rarity) local link = _G.GetLootSlotLink(i) - if link then + if link and rarity >= threshold then table.insert(items,{link=link,mlid=i}) print("Item: ", link, i) end @@ -156,7 +160,7 @@ event:RegisterEvent("LOOT_OPENED",LootOpened) -- todo: what are these - event:RegisterEvent("LOOT_SLOT_CLEARED",function() print("LSCleared") end) + event:RegisterEvent("LOOT_SLOT_CLEARED",function(_,index) InitiateLSClear(index) end) event:RegisterEvent("LOOT_SLOT_CHANGED",function() print("LSChanged") end) RegisterListenerStateChange(statelistener) diff -r 62805e6b46c5 -r db7e4ee34dce State.lua --- a/State.lua Fri Apr 13 22:09:17 2012 -0400 +++ b/State.lua Fri Apr 13 23:14:03 2012 -0400 @@ -357,6 +357,25 @@ Comm:SendStateChange("IR",person,roll) end end + +local function LootSlotCleared(packet) + local index = unpack(packet) + if state == "looting" or state == "bidding" then + for i,v in pairs(stateitemlist) do + if v.mlid == index then + v.disabled = true + print("DISABLING") + AlertItemListListeners() + return + end + end + end +end +function InitiateLSClear(index) + if state == "looting" or state == "bidding" then + Comm:SendStateChange("SC",index) + end +end function DispatchState(packet) local state = table.remove(packet,1) print("Dispatching", state) @@ -376,8 +395,10 @@ ActivateList(packet) elseif state == "IR" then RollRequest(packet) + elseif state == "SC" then + LootSlotCleared(packet) else -- todo ... - + _G.error("Cannot dispatch message of type:",state) end end