i3/etc/compress.lua
Jean-Patrick Guerrero c3f050b737 Some fixes
2021-06-25 17:20:15 +02:00

228 lines
4.3 KiB
Lua

local fmt, insert = string.format, table.insert
local wood_types = {
"acacia_wood", "aspen_wood", "junglewood", "pine_wood",
}
local material_tools = {
"bronze", "diamond", "mese", "stone", "wood",
}
local material_stairs = {
"acacia_wood", "aspen_wood", "brick", "bronzeblock", "cobble", "copperblock",
"desert_cobble", "desert_sandstone", "desert_sandstone_block", "desert_sandstone_brick",
"desert_stone", "desert_stone_block", "desert_stonebrick",
"glass", "goldblock", "ice", "junglewood", "mossycobble", "obsidian",
"obsidian_block", "obsidian_glass", "obsidianbrick", "pine_wood",
"sandstone", "sandstone_block", "sandstonebrick",
"silver_sandstone", "silver_sandstone_block", "silver_sandstone_brick",
"snowblock", "steelblock", "stone", "stone_block", "stonebrick",
"straw", "tinblock",
}
local colors = {
"black", "blue", "brown", "cyan", "dark_green", "dark_grey", "green",
"grey", "magenta", "orange", "pink", "red", "violet", "yellow",
}
local to_compress = {
["bucket:bucket_empty"] = {
replace = "empty",
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 = {
"acacia_bush_sapling",
"acacia_sapling",
"aspen_sapling",
"blueberry_bush_sapling",
"bush_sapling",
"emergent_jungle_sapling",
"junglesapling",
"pine_bush_sapling",
"pine_sapling"
}
},
["default:gold_lump"] = {
replace = "gold",
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 = {
"acacia_bush_leaves",
"acacia_leaves",
"aspen_leaves",
"blueberry_bush_leaves",
"blueberry_bush_leaves_with_berries",
"bush_leaves",
"jungleleaves",
"pine_bush_needles",
"pine_needles",
},
},
["default:stone_with_diamond"] = {
replace = "diamond",
by = {"coal", "copper", "gold", "iron", "mese", "tin"},
},
["default:fence_wood"] = {
replace = "wood",
by = wood_types,
},
["default:fence_rail_wood"] = {
replace = "wood",
by = wood_types,
},
["default:mese_post_light"] = {
replace = "mese_post_light",
by = {
"mese_post_light_acacia",
"mese_post_light_aspen_wood",
"mese_post_light_junglewood",
"mese_post_light_pine_wood",
}
},
["doors:gate_wood_closed"] = {
replace = "wood",
by = wood_types,
},
["doors:door_wood"] = {
replace = "wood",
by = {"glass", "obsidian_glass", "steel"}
},
["flowers:geranium"] = {
replace = "geranium",
by = {
"chrysanthemum_green",
"dandelion_white",
"dandelion_yellow",
"rose",
"tulip",
"tulip_black",
"viola",
}
},
["wool:white"] = {
replace = "white",
by = colors
},
["dye:white"] = {
replace = "white",
by = colors
},
["default:axe_steel"] = {
replace = "steel",
by = material_tools
},
["default:pick_steel"] = {
replace = "steel",
by = material_tools
},
["default:shovel_steel"] = {
replace = "steel",
by = material_tools
},
["default:sword_steel"] = {
replace = "steel",
by = material_tools
},
["farming:hoe_steel"] = {
replace = "steel",
by = {"wood", "stone"}
},
["stairs:slab_wood"] = {
replace = "wood",
by = material_stairs
},
["stairs:stair_wood"] = {
replace = "wood",
by = material_stairs
},
["stairs:stair_inner_wood"] = {
replace = "wood",
by = material_stairs
},
["stairs:stair_outer_wood"] = {
replace = "wood",
by = material_stairs
},
["walls:cobble"] = {
replace = "cobble",
by = {"desertcobble", "mossycobble"}
},
}
local compressed = {}
for k, v in pairs(to_compress) do
compressed[k] = compressed[k] or {}
for _, str in ipairs(v.by) do
local it = k:gsub(v.replace, str)
insert(compressed[k], it)
end
end
local _compressed = {}
for _, v in pairs(compressed) do
for _, v2 in ipairs(v) do
_compressed[v2] = true
end
end
return compressed, _compressed