mirror of
https://github.com/minetest-mods/craftguide.git
synced 2024-11-22 19:03:43 +01:00
Quick fix
This commit is contained in:
parent
3f7ad71e00
commit
e0e57b45ea
25
init.lua
25
init.lua
@ -699,24 +699,31 @@ local function search(data)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local filtered_list, c = {}, 0
|
local filtered_list, c = {}, 0
|
||||||
|
local pattern = "^(.-)%+([%w_]+)=([%w_,]+)"
|
||||||
|
local search_filter = next(search_filters) and match(filter, pattern)
|
||||||
|
local filters = {}
|
||||||
|
|
||||||
|
if search_filter then
|
||||||
|
for filter_name, values in gmatch(filter, sub(pattern, 6, -1)) do
|
||||||
|
if search_filters[filter_name] then
|
||||||
|
values = split(values, ",")
|
||||||
|
filters[filter_name] = values
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
for i = 1, #data.items_raw do
|
for i = 1, #data.items_raw do
|
||||||
local item = data.items_raw[i]
|
local item = data.items_raw[i]
|
||||||
local def = reg_items[item]
|
local def = reg_items[item]
|
||||||
local desc = lower(def.description)
|
local desc = lower(def.description)
|
||||||
local search_in = item .. desc
|
local search_in = item .. desc
|
||||||
local pattern = "%+([%w_]+)=([%w_,]+)"
|
|
||||||
local to_add
|
local to_add
|
||||||
|
|
||||||
if find(filter, pattern) then
|
if search_filter then
|
||||||
local prepend = match(filter, "^(.-)%+")
|
for filter_name, values in pairs(filters) do
|
||||||
for filter_name, values in gmatch(filter, pattern) do
|
|
||||||
local func = search_filters[filter_name]
|
local func = search_filters[filter_name]
|
||||||
if func then
|
to_add = func(item, values) and (not search_filter or
|
||||||
values = split(values, ",")
|
find(search_in, search_filter, 1, true))
|
||||||
to_add = func(item, values) and (not prepend or
|
|
||||||
find(search_in, prepend, 1, true))
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
to_add = find(search_in, filter, 1, true)
|
to_add = find(search_in, filter, 1, true)
|
||||||
|
Loading…
Reference in New Issue
Block a user