Mercurial > wow > breuesk
view Looting.lua @ 77:0a3f590f69e6
Update todo list
Helper function to print list status
author | John@Yosemite-PC |
---|---|
date | Thu, 12 Apr 2012 22:18:05 -0400 |
parents | 39be9328acd0 |
children | 5b507f4125d4 |
line wrap: on
line source
local bsk=bsk local _G=_G local table=table local pairs=pairs local setmetatable=setmetatable local ipairs=ipairs local string=string local sformat=string.format local tostring=tostring local type=type local getn=getn local event = LibStub("AceEvent-3.0") setfenv(1,bsk) local isMasterLootEvent = false local function OpenMasterLootList() print("Open!") isMasterLootEvent = true end local function UpdateMasterLootList() print("Update MLL!") end local function LootClosed() print("Close!") if isMasterLootEvent then isMasterLootEvent = false -- end the event InitiateCloseLooting() end end local function LootOpened() print("Open loot!") isMasterLootEvent = false local n = _G.GetNumLootItems() for i = 1,n do _G.LootSlot(i) end local items = {} for i = 1,n do local link = _G.GetLootSlotLink(i) if link then table.insert(items,link) print("Item: ", link) end end if not isMasterLootEvent then return end print("Let's get started SKing") -- todo: check that I am ML and that I'm an admin! -- make state: gather all item links, transmit them plus the new looting -- state -- InitiateBeginLoot(items,stateactivelist) end function FreeLoot(item,person) PrintTable(item) PrintTable(person) for ci = 1, 40 do if _G.GetMasterLootCandidate(ci) == person.textPlain then print("GML",item.value,ci) _G.GiveMasterLoot(item.value, ci) return true end end print("Could not assign loot to ", person.textPlain) end function ExpensiveLoot(item,lref) local person if getn(statebids) > 0 then if FreeLoot(item,statebids[1]) then lref:SuicidePerson(statebids[1].value) else printf("Could not suicide %s for item; they are ineligible or offline",statebids[1].textPlain) end return end if getn(staterolls) > 0 then if FreeLoot(item,staterolls[1]) then lref:SuicidePerson(staterolls[1].value) else printf("Could not suicide %s for item; they are ineligible or offline",staterolls[1].textPlain) end return end _G.error("Trying to suicide+loot without bids or rolls") 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() print("LSCleared") end) event:RegisterEvent("LOOT_SLOT_CHANGED",function() print("LSChanged") end) end