Some fixes

This commit is contained in:
Jean-Patrick Guerrero 2021-06-25 17:20:15 +02:00
parent 00042c77e1
commit c3f050b737
2 changed files with 46 additions and 10 deletions

View File

@ -31,11 +31,31 @@ local to_compress = {
by = {"lava", "river_water", "water"}
},
["butterflies:butterfly_white"] = {
replace = "white",
by = {"red", "violet"}
},
["default:wood"] = {
replace = "wood",
by = wood_types,
},
["default:tree"] = {
replace = "tree",
by = {"acacia_tree", "aspen_tree", "jungletree", "pine_tree"},
},
["default:grass_1"] = {
replace = "grass_1",
by = {"dry_grass_1", "junglegrass", "marram_grass_1", "fern_1"},
},
["carts:rail"] = {
replace = "rail",
by = {"brakerail", "powerrail"},
},
["default:sapling"] = {
replace = "sapling",
by = {
@ -56,6 +76,11 @@ local to_compress = {
by = {"clay", "coal", "copper", "iron", "tin"}
},
["default:gold_ingot"] = {
replace = "gold_ingot",
by = {"bronze_ingot", "copper_ingot", "steel_ingot", "tin_ingot", "clay_brick"}
},
["default:leaves"] = {
replace = "leaves",
by = {
@ -66,6 +91,8 @@ local to_compress = {
"blueberry_bush_leaves_with_berries",
"bush_leaves",
"jungleleaves",
"pine_bush_needles",
"pine_needles",
},
},
@ -147,6 +174,11 @@ local to_compress = {
by = material_tools
},
["farming:hoe_steel"] = {
replace = "steel",
by = {"wood", "stone"}
},
["stairs:slab_wood"] = {
replace = "wood",
by = material_stairs
@ -166,6 +198,11 @@ local to_compress = {
replace = "wood",
by = material_stairs
},
["walls:cobble"] = {
replace = "cobble",
by = {"desertcobble", "mossycobble"}
},
}
local compressed = {}
@ -173,9 +210,8 @@ local compressed = {}
for k, v in pairs(to_compress) do
compressed[k] = compressed[k] or {}
for _, str in ipairs(v.by) do
local a, b = k:match("(.*):(.*)")
local it = fmt("%s:%s", a, b:gsub(v.replace, str))
for _, str in ipairs(v.by) do
local it = k:gsub(v.replace, str)
insert(compressed[k], it)
end
end

View File

@ -460,12 +460,12 @@ function i3.get_search_filters()
return search_filters
end
local function compression_active()
return item_compression and not next(recipe_filters)
local function compression_active(data)
return item_compression and not next(recipe_filters) and data.filter == ""
end
local function compressible(item)
return compression_active() and compress_groups[item]
local function compressible(item, data)
return compression_active(data) and compress_groups[item]
end
local function weird_desc(str)
@ -1064,7 +1064,7 @@ local function select_item(player, name, data, _f)
if not item then return end
if compressible(item) then
if compressible(item, data) then
local idx
for i = 1, #data.items do
@ -1662,7 +1662,7 @@ local function get_rcp_extra(player, fs, data, panel, is_recipe, is_usage)
end
local function get_items_fs(fs, data, extend)
if compression_active() then
if compression_active(data) then
local new = {}
for i = 1, #data.items do
@ -1722,7 +1722,7 @@ local function get_items_fs(fs, data, extend)
fs[#fs + 1] = fmt("item_image_button", X, Y, size, size, name, item, "")
if compressible(item) then
if compressible(item, data) then
local expand = data.expand == name
fs(fmt("tooltip[%s;%s]", item, expand and ES"Click to hide" or ES"Click to expand"))