tbc loop change part 1

This commit is contained in:
Manuel Simon Hirsig
2017-06-02 19:31:01 +02:00
parent 116f65f109
commit 922638d8a8
3 changed files with 16 additions and 19 deletions
+9 -12
View File
@@ -313,8 +313,7 @@ function M.query(filter_string)
end
local polish_notation_counter = 0
for i = 1, getn(filter.post) do
local component = filter.post[i]
for _, component in ipairs(filter.post) do
if component[1] == 'operator' then
polish_notation_counter = max(polish_notation_counter, 1)
polish_notation_counter = polish_notation_counter + (tonumber(component[2]) or 1) - 1
@@ -325,7 +324,7 @@ function M.query(filter_string)
if polish_notation_counter > 0 then
local suggestions = T
for key in filters do
for key in pairs(filters) do
tinsert(suggestions, strlower(key))
end
tinsert(suggestions, 'and')
@@ -344,8 +343,7 @@ end
function M.queries(filter_string)
local parts = split(filter_string, ';')
local queries = T
for i = 1, getn(parts) do
local str = trim(parts[i])
for _, str in ipairs(parts) do
local query, _, error = query(str)
if not query then
return nil, error
@@ -363,7 +361,7 @@ function suggestions(filter)
tinsert(suggestions, 'and'); tinsert(suggestions, 'or'); tinsert(suggestions, 'not'); tinsert(suggestions, 'tooltip')
for key in filters do tinsert(suggestions, key) end
for key in pairs(filters) do tinsert(suggestions, key) end
-- classes
if not filter.blizzard.class then
@@ -394,8 +392,8 @@ function suggestions(filter)
-- item names
if getn(filter.components) == 0 then
for i = 1, getn(aux_auctionable_items) do
tinsert(suggestions, aux_auctionable_items[i] .. '/exact')
for _, name in ipairs(aux_auctionable_items) do
tinsert(suggestions, name .. '/exact')
end
end
@@ -404,8 +402,7 @@ end
function M.filter_string(components)
local query_builder = query_builder()
for i = 1, getn(components) do
local component = components[i]
for _, component in ipairs(components) do
if component[1] == 'blizzard' then
query_builder.append(component[4] or component[3])
elseif component[1] == 'operator' then
@@ -494,7 +491,7 @@ function blizzard_query(filter)
query.slot = slot_index
query.quality = item_info.quality
else
for key in temp-S('min_level', 'max_level', 'class', 'subclass', 'slot', 'usable', 'quality') do
for key in pairs(temp-S('min_level', 'max_level', 'class', 'subclass', 'slot', 'usable', 'quality')) do
query[key] = index(filters[key], 2)
end
end
@@ -503,7 +500,7 @@ end
function validator(filter)
local validators = T
for i, component in filter.post do
for i, component in pairs(filter.post) do
local type, name, param = unpack(component)
if type == 'filter' then
validators[i] = filters[name].validator(parse_parameter(filters[name].input_type, param))
+6 -6
View File
@@ -220,7 +220,7 @@ end
function M.tooltip_find(pattern, tooltip)
local count = 0
for _, line in tooltip do
for _, line in pairs(tooltip) do
if line.left_text and strfind(line.left_text, pattern) then
count = count + 1
end
@@ -297,7 +297,7 @@ function M.tooltip(setter, arg1, arg2)
end
function item_charges(tooltip)
for _, line in tooltip do
for _, line in pairs(tooltip) do
local pattern = '^' .. gsub(gsub(ITEM_SPELL_CHARGES_P1, '%%d', '(%%d+)'), '%%%d+%$d', '(%%d+)') .. '$'
local _, _, left_charges_string = strfind(line.left_text or '', pattern)
@@ -343,7 +343,7 @@ do
end
function M.durability(tooltip)
for _, line in tooltip do
for _, line in pairs(tooltip) do
local pattern = '^' .. gsub(gsub(DURABILITY_TEMPLATE, '%%d', '(%%d+)'), '%%%d+%$d', '(%%d+)') .. '$'
local _, _, left_durability_string, left_max_durability_string = strfind(line.left_text or '', pattern)
local _, _, right_durability_string, right_max_durability_string = strfind(line.right_text or '', pattern)
@@ -386,7 +386,7 @@ function M.item(item_id, suffix_id)
end
function M.item_class_index(item_class)
for i, class in temp-A(GetAuctionItemClasses()) do
for i, class in pairs(temp-A(GetAuctionItemClasses())) do
if strupper(class) == strupper(item_class) then
return i, class
end
@@ -394,7 +394,7 @@ function M.item_class_index(item_class)
end
function M.item_subclass_index(class_index, item_subclass)
for i, subclass in temp-A(GetAuctionItemSubClasses(class_index)) do
for i, subclass in pairs(temp-A(GetAuctionItemSubClasses(class_index))) do
if strupper(subclass) == strupper(item_subclass) then
return i, subclass
end
@@ -402,7 +402,7 @@ function M.item_subclass_index(class_index, item_subclass)
end
function M.item_slot_index(class_index, subclass_index, slot_name)
for i, slot in temp-A(GetAuctionInvTypes(class_index, subclass_index)) do
for i, slot in pairs(temp-A(GetAuctionInvTypes(class_index, subclass_index))) do
if strupper(_G[slot]) == strupper(slot_name) then
return i, _G[slot]
end
+1 -1
View File
@@ -67,7 +67,7 @@ end
function write_tuple(schema, tuple)
local separator = schema[2]
local parts = temp-T
for i = 3 , getn(schema) do
for i = 3, getn(schema) do
local key, type = next(schema[i])
tinsert(parts, write(type, tuple[key]))
end