public
Description: WoW Addon - Swap a random minipet every time you visit the bank
Homepage: http://www.tekkub.net
Clone URL: git://github.com/tekkub/kennel.git
Click here to lend your support to: kennel and make a donation at www.pledgie.com !
De-dongle
tekkub (author)
Mon May 12 00:16:41 -0700 2008
commit  18e33936e0c88b02e661f33d1af65746d1a66fc5
tree    038fa95085c74577a0a217548a9eaacc98eb44ec
parent  558f5f818ec86319efc007768acfd4f784c4e339
...
12
13
14
15
16
 
 
 
 
 
17
18
19
20
 
 
 
 
 
21
22
23
...
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
 
 
 
 
82
83
84
85
86
 
87
88
89
...
12
13
14
 
 
15
16
17
18
19
20
 
 
 
21
22
23
24
25
26
27
28
...
30
31
32
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
 
57
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
58
59
60
61
62
 
 
 
 
63
64
65
 
0
@@ -12,12 +12,17 @@ local pets = {
0
 }
0
 
0
 
0
-Kennel = DongleStub("Dongle-1.0"):New("Kennel")
0
-
0
+local function DoSwaps(set)
0
+ local l, g = pets[set].player, pets[set].bank
0
+ if l.num == 0 then return end
0
+ for i=1,l.num do
0
+ local r = math.random(g.num + 1 - i)
0
 
0
-function Kennel:Enable()
0
- self:RegisterEvent("BANKFRAME_OPENED")
0
- self:RegisterEvent("BANKFRAME_CLOSED")
0
+ PickupContainerItem(l.bag[i], l.slot[i])
0
+ PickupContainerItem(g.bag[r], g.slot[r])
0
+ table.remove(g.bag, r)
0
+ table.remove(g.slot, r)
0
+ end
0
 end
0
 
0
 
0
@@ -25,65 +30,36 @@ end
0
 --      Event handlers      --
0
 ------------------------------
0
 
0
-function Kennel:BANKFRAME_CLOSED()
0
- if bankopen and swapped and FuBar_CorkFu then FuBar_CorkFu:GetModule("Minipet"):ActivatePet() end
0
- bankopen = nil
0
-end
0
-
0
-
0
-function Kennel:BANKFRAME_OPENED()
0
- bankopen = true
0
- swapped = false
0
-
0
- pets.normal.player.num = 0
0
- pets.normal.bank.num = 0
0
- pets.holiday.player.num = 0
0
- pets.holiday.bank.num = 0
0
-
0
- for bag=-1,11 do
0
- local bagset = (bag <= 4) and (bag >= 0) and "player" or "bank"
0
- for slot=1,GetContainerNumSlots(bag) do
0
- local itemLink = GetContainerItemLink(bag, slot)
0
- if (itemLink and pt(itemLink, "Minipet")) then
0
- local n = pets.normal[bagset].num + 1
0
- pets.normal[bagset].num = n
0
- pets.normal[bagset].bag[n] = bag
0
- pets.normal[bagset].slot[n] = slot
0
- elseif (itemLink and pt(itemLink, "Minipet - Holiday")) then
0
- local n = pets.holiday[bagset].num + 1
0
- pets.holiday[bagset].num = n
0
- pets.holiday[bagset].bag[n] = bag
0
- pets.holiday[bagset].slot[n] = slot
0
+local f = CreateFrame("frame")
0
+f:RegisterEvent("BANKFRAME_OPENED")
0
+f:RegisterEvent("BANKFRAME_CLOSED")
0
+f:SetScript("OnEvent", function(self, event, ...)
0
+ if event == "BANKFRAME_CLOSED" then
0
+ if bankopen and swapped and FuBar_CorkFu then FuBar_CorkFu:GetModule("Minipet"):ActivatePet() end
0
+ bankopen = nil
0
+ else
0
+ bankopen, swapped = true, false
0
+ pets.normal.player.num, pets.normal.bank.num, pets.holiday.player.num, pets.holiday.bank.num = 0, 0, 0, 0
0
+
0
+ for bag=-1,11 do
0
+ local bagset = (bag <= 4) and (bag >= 0) and "player" or "bank"
0
+ for slot=1,GetContainerNumSlots(bag) do
0
+ local itemLink = GetContainerItemLink(bag, slot)
0
+ if (itemLink and pt(itemLink, "Minipet")) then
0
+ local n = pets.normal[bagset].num + 1
0
+ pets.normal[bagset].num, pets.normal[bagset].bag[n], pets.normal[bagset].slot[n] = n, bag, slot
0
+ elseif (itemLink and pt(itemLink, "Minipet - Holiday")) then
0
+ local n = pets.holiday[bagset].num + 1
0
+ pets.holiday[bagset].num, pets.holiday[bagset].bag[n], pets.holiday[bagset].slot[n] = n, bag, slot
0
+ end
0
       end
0
     end
0
- end
0
 
0
- if pets.normal.player.num > pets.normal.bank.num then
0
- pets.normal.player, pets.normal.bank = pets.normal.bank, pets.normal.player
0
- end
0
- if pets.holiday.player.num > pets.holiday.bank.num then
0
- pets.holiday.player, pets.holiday.bank = pets.holiday.bank, pets.holiday.player
0
- end
0
- self:DoSwaps("normal")
0
- self:DoSwaps("holiday")
0
-
0
- if (pets.normal.player.num > 0 and pets.normal.bank.num > 0)
0
- or (pets.holiday.player.num > 0 and pets.holiday.bank.num > 0) then
0
- swapped = true
0
- end
0
-end
0
-
0
-
0
-function Kennel:DoSwaps(set)
0
- local l, g = pets[set].player, pets[set].bank
0
- if l.num == 0 then return end
0
- for i=1,l.num do
0
- local r = math.random(g.num + 1 - i)
0
+ if pets.normal.player.num > pets.normal.bank.num then pets.normal.player, pets.normal.bank = pets.normal.bank, pets.normal.player end
0
+ if pets.holiday.player.num > pets.holiday.bank.num then pets.holiday.player, pets.holiday.bank = pets.holiday.bank, pets.holiday.player end
0
+ DoSwaps("normal")
0
+ DoSwaps("holiday")
0
 
0
- PickupContainerItem(l.bag[i], l.slot[i])
0
- PickupContainerItem(g.bag[r], g.slot[r])
0
- table.remove(g.bag, r)
0
- table.remove(g.slot, r)
0
+ if (pets.normal.player.num > 0 and pets.normal.bank.num > 0) or (pets.holiday.player.num > 0 and pets.holiday.bank.num > 0) then swapped = true end
0
   end
0
 end
0
-
...
8
9
10
11
12
13
14
15
16
17
18
19
20
 
...
8
9
10
 
 
11
12
13
 
14
15
 
16
17
0
@@ -8,12 +8,9 @@
0
 ## X-Email: tekkub-wow@googlegroups.com
0
 ## X-Category: Inventory
0
 
0
-## OptionalDeps: Dongle
0
-
0
 ## LoadManagers: AddonLoader
0
 ## X-LoadOn-Bank: true
0
 
0
-Dongle.lua
0
 PeriodicTableMicro.lua
0
 
0
-Kennel.lua
0
\ No newline at end of file
0
+Kennel.lua

Comments

    No one has commented yet.