comparison Looting.lua @ 73:7eb2963eea7d

Further splitting up GUI and State Starting to integrate looting events
author John@Yosemite-PC
date Sun, 08 Apr 2012 22:13:17 -0400
parents
children 39be9328acd0
comparison
equal deleted inserted replaced
72:9e5b0a2368ad 73:7eb2963eea7d
1 local bsk=bsk
2 local _G=_G
3 local table=table
4 local pairs=pairs
5 local setmetatable=setmetatable
6 local ipairs=ipairs
7 local string=string
8 local sformat=string.format
9 local tostring=tostring
10 local type=type
11 local getn=getn
12
13 local event = LibStub("AceEvent-3.0")
14
15 setfenv(1,bsk)
16
17 local isMasterLootEvent = false
18
19 local function OpenMasterLootList()
20 print("Open!")
21 isMasterLootEvent = true
22 end
23
24 local function UpdateMasterLootList()
25 print("Update MLL!")
26 end
27
28 local function LootClosed()
29 print("Close!")
30 if isMasterLootEvent then
31 isMasterLootEvent = false -- end the event
32 InitiateCloseLooting()
33 end
34 end
35
36 local function LootOpened()
37 print("Open loot!")
38 isMasterLootEvent = false
39 local n = _G.GetNumLootItems()
40 for i = 1,n do
41 _G.LootSlot(i)
42 end
43 local items = {}
44 for i = 1,n do
45 local link = _G.GetLootSlotLink(i)
46 if link then
47 table.insert(items,link)
48 print("Item: ", link)
49 end
50 end
51 if not isMasterLootEvent then return end
52
53 print("Let's get started SKing")
54 -- todo: check that I am ML and that I'm an admin!
55
56 -- make state: gather all item links, transmit them plus the new looting
57 -- state
58 --
59 InitiateBeginLoot(items,stateactivelist)
60
61 end
62
63 function InitializeLooting()
64 event:RegisterEvent("OPEN_MASTER_LOOT_LIST",OpenMasterLootList)
65 event:RegisterEvent("UPDATE_MASTER_LOOT_LIST",UpdateMasterLootList)
66 event:RegisterEvent("LOOT_CLOSED",LootClosed)
67 event:RegisterEvent("LOOT_OPENED",LootOpened)
68 end
69