mirror of
https://github.com/minetest-mods/unified_inventory.git
synced 2024-08-20 13:24:10 +02:00
Respect not_in_creative_inventory in group search
This commit is contained in:
parent
12ef7f6393
commit
79320c109c
43
internal.lua
43
internal.lua
@ -96,46 +96,37 @@ end
|
|||||||
--apply filter to the inventory list (create filtered copy of full one)
|
--apply filter to the inventory list (create filtered copy of full one)
|
||||||
function unified_inventory.apply_filter(player, filter)
|
function unified_inventory.apply_filter(player, filter)
|
||||||
local player_name = player:get_player_name()
|
local player_name = player:get_player_name()
|
||||||
local size = 0
|
|
||||||
local lfilter = string.lower(filter)
|
local lfilter = string.lower(filter)
|
||||||
if not pcall(function() ("technic:test"):find(lfilter) end) then
|
if not pcall(function() ("technic:test"):find(lfilter) end) then
|
||||||
-- Filter is invalid
|
-- Filter is invalid
|
||||||
lfilter = ""
|
lfilter = ""
|
||||||
end
|
end
|
||||||
unified_inventory.filtered_items_list[player_name]={}
|
local ffilter
|
||||||
if lfilter:sub(1, 6) == "group:" then
|
if lfilter:sub(1, 6) == "group:" then
|
||||||
local groups = lfilter:sub(7):split(",")
|
local groups = lfilter:sub(7):split(",")
|
||||||
for name, def in pairs(minetest.registered_items) do
|
ffilter = function(name, def)
|
||||||
if def.groups then
|
for _, group in ipairs(groups) do
|
||||||
local all = true
|
if not ((def.groups[group] or 0) > 0) then
|
||||||
for _, group in ipairs(groups) do
|
return false
|
||||||
if not (def.groups[group] and (def.groups[group] > 0)) then
|
|
||||||
all = false
|
|
||||||
break
|
|
||||||
end
|
|
||||||
end
|
|
||||||
if all then
|
|
||||||
table.insert(unified_inventory.filtered_items_list[player_name], name)
|
|
||||||
size = size + 1
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
return true
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
for name, def in pairs(minetest.registered_items) do
|
ffilter = function(name, def)
|
||||||
if (not def.groups.not_in_creative_inventory or
|
local lname = string.lower(name)
|
||||||
def.groups.not_in_creative_inventory == 0)
|
local ldesc = string.lower(def.description)
|
||||||
and def.description and def.description ~= "" then
|
return string.find(lname, lfilter) or string.find(ldesc, lfilter)
|
||||||
local lname = string.lower(name)
|
end
|
||||||
local ldesc = string.lower(def.description)
|
end
|
||||||
if string.find(lname, lfilter) or string.find(ldesc, lfilter) then
|
unified_inventory.filtered_items_list[player_name]={}
|
||||||
table.insert(unified_inventory.filtered_items_list[player_name], name)
|
for name, def in pairs(minetest.registered_items) do
|
||||||
size = size + 1
|
if (def.groups.not_in_creative_inventory or 0) == 0 and (def.description or "") ~= "" and ffilter(name, def) then
|
||||||
end
|
table.insert(unified_inventory.filtered_items_list[player_name], name)
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
table.sort(unified_inventory.filtered_items_list[player_name])
|
table.sort(unified_inventory.filtered_items_list[player_name])
|
||||||
unified_inventory.filtered_items_list_size[player_name] = size
|
unified_inventory.filtered_items_list_size[player_name] = #unified_inventory.filtered_items_list[player_name]
|
||||||
unified_inventory.current_index[player_name] = 1
|
unified_inventory.current_index[player_name] = 1
|
||||||
unified_inventory.activefilter[player_name] = filter
|
unified_inventory.activefilter[player_name] = filter
|
||||||
unified_inventory.set_inventory_formspec(player,
|
unified_inventory.set_inventory_formspec(player,
|
||||||
|
@ -162,7 +162,7 @@ local function compute_group_representative_item(groupspec)
|
|||||||
local groupname = string.sub(groupspec, 7)
|
local groupname = string.sub(groupspec, 7)
|
||||||
local candidate_items = {}
|
local candidate_items = {}
|
||||||
for itemname, itemdef in pairs(minetest.registered_items) do
|
for itemname, itemdef in pairs(minetest.registered_items) do
|
||||||
if itemdef.groups[groupname] and itemdef.groups[groupname] ~= 0 then
|
if (itemdef.groups.not_in_creative_inventory or 0) == 0 and (itemdef.groups[groupname] or 0) ~= 0 then
|
||||||
table.insert(candidate_items, itemname)
|
table.insert(candidate_items, itemname)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user