vanilla-wow-addons – Blame information for rev 1

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 office 1 ----------------------------------------------------------------
2 -- AutoProfit v2.55 (January 2006)
3 -- Check out www.gameguidesonline.com for the latest version.
4 -- To learn how I used the 3D model read this: (http://www.gameguidesonline.com/guides/articles/ggoarticleoctober05_02.asp)
5 -- Written by Jason Allen.
6 ----------------------------------------------------------------
7  
8 autoProfitExceptions = { };
9 totalProfit = 0;
10 rotation = 0;
11 rotrate = 0;
12 AUTOPROFIT_VERSION = "v2.55 January 6th, 2006";
13  
14 function SellJunk()
15  
16 local numOfSales = 0;
17  
18  
19 for bag = 0, 4 do
20  
21 if GetContainerNumSlots(bag) > 0 then
22  
23 for slot = 0, GetContainerNumSlots(bag) do
24  
25 local texture, itemCount, locked, quality = GetContainerItemInfo(bag, slot);
26  
27 if (quality == 0) then
28 local result = AutoSeller_ProcessLink(GetContainerItemLink(bag, slot));
29 if (result > 0) then
30 DEFAULT_CHAT_FRAME:AddMessage("|c00bfffffAutoProfit|r: Sold " .. GetContainerItemLink(bag, slot), 0.0, .8, 1);
31 PickupContainerItem(bag, slot);
32 MerchantItemButton_OnClick("LeftButton");
33 end
34 end
35  
36 if (quality == -1) then
37 local linkcolor = AutoSeller_ProcessLink(GetContainerItemLink(bag, slot));
38 if (linkcolor == 1) then
39 DEFAULT_CHAT_FRAME:AddMessage("|c00bfffffAutoProfit|r: Sold " .. GetContainerItemLink(bag, slot), 0.0, .8, 1);
40 PickupContainerItem(bag, slot);
41 MerchantItemButton_OnClick("LeftButton");
42 end
43  
44 end
45  
46  
47 end
48  
49 end
50 end
51  
52 end
53  
54 function AutoProfit_OnLoad()
55 SLASH_AUTOPROFIT1 = "/autoprofit";
56 SLASH_AUTOPROFIT2 = "/ap";
57 SlashCmdList["AUTOPROFIT"] = AutoProfit_SlashCmd;
58 end
59  
60 function AutoProfit_Calculate()
61  
62 for bag = 0, 4 do
63  
64 if GetContainerNumSlots(bag) > 0 then
65  
66 for slot = 0, GetContainerNumSlots(bag) do
67  
68 local texture, itemCount, locked, quality = GetContainerItemInfo(bag, slot);
69  
70 if (quality == 0) then
71 local result = AutoSeller_ProcessLink(GetContainerItemLink(bag, slot));
72 if (result > 0) then
73 AutoProfit_Tooltip:SetBagItem(bag, slot);
74 end
75 end
76  
77 if (quality == -1) then
78 local linkcolor = AutoSeller_ProcessLink(GetContainerItemLink(bag, slot));
79 if (linkcolor == 1) then
80 AutoProfit_Tooltip:SetBagItem(bag, slot);
81 end
82  
83 end
84  
85 end
86  
87 end
88 end
89  
90  
91 end
92  
93 function AutoProfit_AddCoin()
94  
95 if (arg1) then
96 totalProfit = totalProfit + arg1;
97 end
98 end
99  
100 function AutoProfit_RotateModel(elapsed)
101  
102 if (rotrate > 0) then rotation = rotation + (elapsed * rotrate); end
103  
104 TreasureModel:SetRotation(rotation);
105  
106 end;
107  
108  
109 function AutoProfit_SlashCmd(msg)
110  
111 --No switch statement in Lua? Lots of ugly if's to follow.
112  
113 if (msg == "") then
114 DEFAULT_CHAT_FRAME:AddMessage("|c00bfffffAutoProfit|r " .. AUTOPROFIT_VERSION .. " by Jason Allen.", 0.0, .80, 1);
115 DEFAULT_CHAT_FRAME:AddMessage("|c00bfffff/autoprofit [item link]|r: Add an item to the exception list.", 0.0, .80, 1);
116 DEFAULT_CHAT_FRAME:AddMessage("|c00bfffff/autoprofit [item link]|r: Removes that item from the exception list.", 0.0, .80, 1);
117 DEFAULT_CHAT_FRAME:AddMessage("|c00bfffff/autoprofit list|r: List all items on your exception list.", 0.0, .80, 1);
118 DEFAULT_CHAT_FRAME:AddMessage("|c00bfffff/autoprofit [number]|r: Remove item at that location in your exception list.", 0.0, .80, 1);
119 DEFAULT_CHAT_FRAME:AddMessage("|c00bfffff/autoprofit purge|r: Remove all items from your exception list.", 0.0, .80, 1);
120 DEFAULT_CHAT_FRAME:AddMessage("For the latest version and advanced usage visit |c00bfffffwww.gameguidesonline.com|r (Under the World of Warcraft mods menu.)", 0.0, .80, 1);
121 return;
122 end
123  
124 if (msg == "purge") then
125 autoProfitExceptions = { };
126 DEFAULT_CHAT_FRAME:AddMessage("|c00bfffffAutoProfit|r: Deleted all exceptions.", 0.0, .80, 1);
127 return;
128 end
129  
130 if (msg == "list") then
131 if (table.getn(autoProfitExceptions) > 0) then
132 DEFAULT_CHAT_FRAME:AddMessage("AutoProfit Exceptions: ", 0.0, .80, 1);
133 for i=1,table.getn(autoProfitExceptions) do
134 DEFAULT_CHAT_FRAME:AddMessage("[|c00bfffff" .. i .. "|r] " .. autoProfitExceptions[i], 0.0, .80, 1);
135 end
136 else
137 DEFAULT_CHAT_FRAME:AddMessage("|c00bfffffAutoProfit|r: Your exceptions list is empty.", 0.0, .80, 1);
138 end
139 return;
140 end
141  
142 if (string.len(msg) < 5) then
143  
144 if (tonumber(msg) == nil) then return; end
145  
146 if (tonumber(msg) > table.getn(autoProfitExceptions)) then
147 return;
148 else
149 DEFAULT_CHAT_FRAME:AddMessage("|c00bfffffAutoProfit|r: Removed " .. autoProfitExceptions[tonumber(msg)] .. " from exceptions list.", 0.0, .8, 1);
150 table.remove(autoProfitExceptions, tonumber(msg));
151 return;
152 end
153 end
154  
155 if (string.find(msg, "Hitem:") == nil) then return; end
156  
157 local removed = 0;
158  
159 if (table.getn(autoProfitExceptions) > 0) then
160  
161 for i=1,table.getn(autoProfitExceptions) do
162  
163 if (msg == autoProfitExceptions[i]) then
164 DEFAULT_CHAT_FRAME:AddMessage("|c00bfffffAutoProfit|r: Removed " .. autoProfitExceptions[i] .. " from exceptions list.", 0.0, .8, 1);
165 table.remove(autoProfitExceptions, i);
166 removed = 1;
167 end
168 end
169 end
170  
171 if (removed == 0) then
172 table.insert(autoProfitExceptions, msg);
173 DEFAULT_CHAT_FRAME:AddMessage("|c00bfffffAutoProfit|r: Added " .. msg .. " to exceptions list.", 0.0, .8, 1);
174 end
175  
176  
177  
178 end
179  
180  
181 function AutoSeller_ProcessLink(link)
182  
183 local color;
184 local item;
185 local name;
186  
187 for color, item, name in string.gfind(link, "|c(%x+)|Hitem:(%d+:%d+:%d+:%d+)|h%[(.-)%]|h|r") do
188  
189 --This prevents Dark Moon Faire items from being sold to the vendor.
190 if ((name == "Small Furry Paw") or (name == "Torn Bear Pelt") or (name == "Soft Bushy Tail") or (name == "Vibrant Plume") or (name == "Evil Bat Eye")
191 or (name == "Glowing Scorpid Blood")) then
192 return 0;
193 end
194  
195 if (color == "ff9d9d9d") then
196 for i=1,table.getn(autoProfitExceptions) do
197  
198 if (link == autoProfitExceptions[i]) then
199 return 0;
200 end
201 end
202  
203  
204 return 1;
205 end
206  
207 if (color == "ffffffff") then
208 for i=1,table.getn(autoProfitExceptions) do
209  
210 if (link == autoProfitExceptions[i]) then
211  
212 return 1;
213 end
214 end
215  
216 return 0;
217 end
218  
219 return 0;
220 end
221  
222 end