comparison Modules/CraftingRules.lua @ 108:706b173b0fa1

Ticket 20 - Added a Bonus Queue to the Crafting Rules
author Asa Ayers <Asa.Ayers@Gmail.com>
date Tue, 24 Aug 2010 22:40:07 -0700
parents f1a013c64270
children 090e466fd956
comparison
equal deleted inserted replaced
107:f1a013c64270 108:706b173b0fa1
16 if nil == rule.target then 16 if nil == rule.target then
17 rule.target = 0 17 rule.target = 0
18 end 18 end
19 if nil == rule.skip_singles then 19 if nil == rule.skip_singles then
20 rule.skip_singles = false 20 rule.skip_singles = false
21 end
22 if nil == rule.bonus_queue then
23 rule.bonus_queue = 0
21 end 24 end
22 return rule 25 return rule
23 end 26 end
24 27
25 local print = function(message, ...) 28 local print = function(message, ...)
108 set = function(info, value) 111 set = function(info, value)
109 ItemAuditor.db.char.rules[name].skip_singles = value 112 ItemAuditor.db.char.rules[name].skip_singles = value
110 end, 113 end,
111 order = 12, 114 order = 12,
112 }, 115 },
116 bonus_queue = {
117 type = "range",
118 name = "Bonus Queue",
119 desc = "If don't have any of an item, this number will be added to the number to craft.",
120 min = 0,
121 max = 1000,
122 softMax = 50,
123 step = 1,
124 get = function() return ItemAuditor.db.char.rules[name].bonus_queue end,
125 set = function(info, value)
126 ItemAuditor.db.char.rules[name].bonus_queue = value
127 end,
128 order = 13,
129 },
113 header_delete = { 130 header_delete = {
114 type = 'header', 131 type = 'header',
115 name = '', 132 name = '',
116 order = 19, 133 order = 19,
117 }, 134 },
191 end 208 end
192 end 209 end
193 210
194 local function runRule(rule, itemName, itemID, data) 211 local function runRule(rule, itemName, itemID, data)
195 local searches = {strsplit(',', rule.search:upper())} 212 local searches = {strsplit(',', rule.search:upper())}
213 local bonus = 0
214 if data.count == 0 then
215 bonus = rule.bonus_queue
216 end
196 217
197 for _, search in pairs(searches) do 218 for _, search in pairs(searches) do
198 search = search:trim() 219 search = search:trim()
199 220
200 if string.find(itemName, search) ~= nil or itemID == search then 221 if string.find(itemName, search) ~= nil or itemID == search then
201 if rule.skip_singles and data.count+1 == rule.target then 222 if rule.skip_singles and data.count+1 == rule.target then
202 return data.count 223 return data.count
203 end 224 end
204 return rule.target 225 return rule.target + bonus
205 end 226 end
206 end 227 end
207 return 0 228 return 0
208 end 229 end
209 230