From 0d5cab94559d34a075d9607829d9b1b09c383992 Mon Sep 17 00:00:00 2001 From: wsor4035 <24964441+wsor4035@users.noreply.github.com> Date: Sun, 3 Mar 2024 15:52:58 -0500 Subject: [PATCH] replace hardcoded game agnostic texture support and homedecor.textures to xcompat (#66) * switch existing to xcompat textures * replace the rest of the hard coded texture conversions to use homedecor.textures --- building_blocks/node_stairs.lua | 14 ++++------ fake_fire/init.lua | 2 +- homedecor_bathroom/init.lua | 4 +-- homedecor_bedroom/init.lua | 2 +- homedecor_climate_control/init.lua | 2 +- homedecor_clocks/init.lua | 10 ++----- homedecor_common/init.lua | 3 +- homedecor_common/materials.lua | 1 - homedecor_common/textures.lua | 34 ----------------------- homedecor_common/xcompat.lua | 8 ++++++ homedecor_exterior/init.lua | 5 ++-- homedecor_furniture/init.lua | 2 +- homedecor_kitchen/init.lua | 2 +- homedecor_laundry/init.lua | 3 +- homedecor_lighting/init.lua | 5 ++-- homedecor_misc/init.lua | 4 +-- homedecor_pictures_and_paintings/init.lua | 2 +- homedecor_roofing/init.lua | 7 ++--- homedecor_seating/armchairs.lua | 6 ++-- homedecor_seating/misc.lua | 2 +- homedecor_windows_and_treatments/init.lua | 2 +- 21 files changed, 40 insertions(+), 80 deletions(-) delete mode 100644 homedecor_common/materials.lua delete mode 100644 homedecor_common/textures.lua create mode 100644 homedecor_common/xcompat.lua diff --git a/building_blocks/node_stairs.lua b/building_blocks/node_stairs.lua index d45e21a8..349c4bcb 100644 --- a/building_blocks/node_stairs.lua +++ b/building_blocks/node_stairs.lua @@ -76,10 +76,11 @@ building_blocks_stairs("building_blocks:Adobe", { key = "node_sound_stone_defaults", }, }) -local grasstex = {"[combine:16x16^[noalpha^[colorize:#006400"} -if minetest.get_modpath("default") then - grasstex = {"default_grass.png", "default_dirt.png", "default_dirt.png^default_grass_side.png"} -end +local grasstex = { + homedecor.textures.grass.top, + homedecor.textures.grass.dirt, + homedecor.textures.grass.side +} building_blocks_stairs("building_blocks:fakegrass", { tiles = grasstex, description = S("Fake Grass"), @@ -147,10 +148,7 @@ minetest.register_node("building_blocks:brobble_spread", { }) if not minetest.get_modpath("moreblocks") or not minetest.get_modpath("gloopblocks") then - local graveltex = "[combine:16x16^[noalpha^[colorize:#3a3b3c" - if minetest.get_modpath("default") then - graveltex = "default_gravel.png" - end + local graveltex = homedecor.textures.gravel minetest.register_node("building_blocks:gravel_spread", { drawtype = "raillike", description = S("Gravel Spread"), diff --git a/fake_fire/init.lua b/fake_fire/init.lua index 20a26e87..b718c821 100644 --- a/fake_fire/init.lua +++ b/fake_fire/init.lua @@ -178,7 +178,7 @@ local sbox = { fixed = { -8/16, -8/16, -8/16, 8/16, -6/16, 8/16}, } -local wtex = homedecor.textures.default_junglewood +local wtex = homedecor.textures.wood.jungle.planks minetest.register_node("fake_fire:fancy_fire", { inventory_image = "fancy_fire_inv.png", diff --git a/homedecor_bathroom/init.lua b/homedecor_bathroom/init.lua index c3e7fbb8..cd2e1e5e 100644 --- a/homedecor_bathroom/init.lua +++ b/homedecor_bathroom/init.lua @@ -2,8 +2,8 @@ local S = minetest.get_translator("homedecor_bathroom") local sc_disallow = minetest.get_modpath("screwdriver") and screwdriver.disallow or nil -local wood_tex = homedecor.textures.default_wood -local water_tex = homedecor.textures.water +local wood_tex = homedecor.textures.wood.apple.planks +local water_tex = homedecor.textures.water.tile homedecor.register("bathroom_tiles_dark", { description = S("Bathroom/kitchen tiles (dark)"), diff --git a/homedecor_bedroom/init.lua b/homedecor_bedroom/init.lua index b8666daa..f0a6cddf 100644 --- a/homedecor_bedroom/init.lua +++ b/homedecor_bedroom/init.lua @@ -2,7 +2,7 @@ local S = minetest.get_translator("homedecor_bedroom") local sc_disallow = minetest.get_modpath("screwdriver") and screwdriver.disallow or nil -local wood_tex, wool_tex = homedecor.textures.default_wood, homedecor.textures.wool_white +local wood_tex, wool_tex = homedecor.textures.wood.apple.planks, homedecor.textures.wool.white local bed_sbox = { type = "wallmounted", diff --git a/homedecor_climate_control/init.lua b/homedecor_climate_control/init.lua index 1d23e54b..dbe2a0d0 100644 --- a/homedecor_climate_control/init.lua +++ b/homedecor_climate_control/init.lua @@ -7,7 +7,7 @@ homedecor.register("air_conditioner", { mesh = "homedecor_ac.obj", tiles = { "homedecor_ac.png", - homedecor.textures.glass + homedecor.textures.glass.pane }, groups = { snappy = 3, dig_stone = 3 }, use_texture_alpha = "clip", diff --git a/homedecor_clocks/init.lua b/homedecor_clocks/init.lua index 79035110..854a4b50 100644 --- a/homedecor_clocks/init.lua +++ b/homedecor_clocks/init.lua @@ -1,12 +1,6 @@ local S = minetest.get_translator("homedecor_clocks") -local wood -if minetest.get_modpath("default") then - wood = "default_wood.png" -else - - wood = "[combine:16x16^[noalpha^[colorize:#563d2d" -end +local wood = homedecor.textures.wood.apple.planks local plastic_craft = { output = "homedecor:analog_clock_plastic 2", @@ -135,7 +129,7 @@ homedecor.register("grandfather_clock", { description = S("Grandfather Clock"), mesh = "homedecor_grandfather_clock.obj", tiles = { - homedecor.textures.glass, + homedecor.textures.glass.pane, "homedecor_grandfather_clock_face.png", homedecor.lux_wood, "homedecor_grandfather_clock_face_edge.png", diff --git a/homedecor_common/init.lua b/homedecor_common/init.lua index a579597b..0b219021 100644 --- a/homedecor_common/init.lua +++ b/homedecor_common/init.lua @@ -54,8 +54,7 @@ homedecor.color_dark_grey = 0xff606060 homedecor.color_med_grey = 0xffa0a0a0 -- load different handler subsystems -dofile(modpath.."/textures.lua") -dofile(modpath.."/materials.lua") +dofile(modpath.."/xcompat.lua") dofile(modpath.."/nodeboxes.lua") dofile(modpath.."/expansion.lua") dofile(modpath.."/furnaces.lua") diff --git a/homedecor_common/materials.lua b/homedecor_common/materials.lua deleted file mode 100644 index 52b5fb43..00000000 --- a/homedecor_common/materials.lua +++ /dev/null @@ -1 +0,0 @@ -homedecor.materials = xcompat.materials \ No newline at end of file diff --git a/homedecor_common/textures.lua b/homedecor_common/textures.lua deleted file mode 100644 index 77a88307..00000000 --- a/homedecor_common/textures.lua +++ /dev/null @@ -1,34 +0,0 @@ -homedecor.plain_wood = { name = "homedecor_generic_wood_plain.png", color = 0xffa76820 } -homedecor.mahogany_wood = { name = "homedecor_generic_wood_plain.png", color = 0xff7d2506 } -homedecor.white_wood = "homedecor_generic_wood_plain.png" -homedecor.dark_wood = { name = "homedecor_generic_wood_plain.png", color = 0xff39240f } -homedecor.lux_wood = { name = "homedecor_generic_wood_luxury.png", color = 0xff643f23 } - -homedecor.textures = { - glass = - "[combine:16x16:" .. - "0,0=\\[combine\\:1x16\\^[noalpha\\^[colorize\\:#ffffff:" .. - "0,0=\\[combine\\:16x1\\^[noalpha\\^[colorize\\:#ffffff:" .. - "0,15=\\[combine\\:16x1\\^[noalpha\\^[colorize\\:#ffffff:" .. - "15,0=\\[combine\\:1x16\\^[noalpha\\^[colorize\\:#ffffff", - default_wood = "[combine:16x16^[noalpha^[colorize:#654321", - default_junglewood = "[combine:16x16^[noalpha^[colorize:#563d2d", - water = "[combine:16x16^[noalpha^[colorize:#00008b", - wool_white = "[combine:16x16^[noalpha^[colorize:#ffffff", - wool_black = "[combine:16x16^[noalpha^[colorize:#000000", - wool_grey = "[combine:16x16^[noalpha^[colorize:#313b3c", - wool_dark_grey = "[combine:16x16^[noalpha^[colorize:#313b3c", -} - -if minetest.get_modpath("default") then - homedecor.textures = { - glass = "default_glass.png", - default_wood = "default_wood.png", - default_junglewood = "default_junglewood.png", - water = "default_water.png", - wool_white = "wool_white.png", - wool_black = "wool_black.png", - wool_grey = "wool_grey.png", - wool_dark_grey = "wool_dark_grey.png", - } -end \ No newline at end of file diff --git a/homedecor_common/xcompat.lua b/homedecor_common/xcompat.lua new file mode 100644 index 00000000..1efe2ba5 --- /dev/null +++ b/homedecor_common/xcompat.lua @@ -0,0 +1,8 @@ +homedecor.plain_wood = { name = "homedecor_generic_wood_plain.png", color = 0xffa76820 } +homedecor.mahogany_wood = { name = "homedecor_generic_wood_plain.png", color = 0xff7d2506 } +homedecor.white_wood = "homedecor_generic_wood_plain.png" +homedecor.dark_wood = { name = "homedecor_generic_wood_plain.png", color = 0xff39240f } +homedecor.lux_wood = { name = "homedecor_generic_wood_luxury.png", color = 0xff643f23 } + +homedecor.materials = xcompat.materials +homedecor.textures = xcompat.textures \ No newline at end of file diff --git a/homedecor_exterior/init.lua b/homedecor_exterior/init.lua index 8a835f7c..7fbc4668 100644 --- a/homedecor_exterior/init.lua +++ b/homedecor_exterior/init.lua @@ -43,7 +43,7 @@ homedecor.register("barbecue", { minetest.register_alias("homedecor:barbecue_meat", "air") -local wood_tex = homedecor.textures.default_wood +local wood_tex = homedecor.textures.wood.apple.planks homedecor.register("doghouse", { mesh = "homedecor_doghouse.obj", @@ -288,8 +288,7 @@ homedecor.register("swing_rope", { selection_box = homedecor.nodebox.null }) -local water_tex = "default_water.png" -if not minetest.get_modpath("default") then water_tex = "[combine:16x16^[noalpha^[colorize:#00008b" end +local water_tex = homedecor.textures.water.tile local cobble_tex = minetest.registered_nodes["mapgen_stone"].tiles[1] local stone_drop = minetest.registered_nodes["mapgen_stone"].drop if stone_drop and type(stone_drop) == "string" then diff --git a/homedecor_furniture/init.lua b/homedecor_furniture/init.lua index c40d6ada..9c7e33af 100644 --- a/homedecor_furniture/init.lua +++ b/homedecor_furniture/init.lua @@ -5,7 +5,7 @@ local ob_cbox = { fixed = { -0.5, -0.5, 0, 0.5, 0.5, 0.5 } } -local wood_tex = homedecor.textures.default_wood +local wood_tex = homedecor.textures.wood.apple.planks homedecor.register("openframe_bookshelf", { description = S("Bookshelf (open-frame)"), diff --git a/homedecor_kitchen/init.lua b/homedecor_kitchen/init.lua index f62d69ff..526d8c59 100644 --- a/homedecor_kitchen/init.lua +++ b/homedecor_kitchen/init.lua @@ -145,7 +145,7 @@ homedecor.register("dishwasher_"..m, { }) end -local wood_tex = homedecor.textures.default_wood +local wood_tex = homedecor.textures.wood.apple.planks local cabinet_sides = "("..wood_tex.."^[transformR90)^homedecor_kitchen_cabinet_bevel.png" local cabinet_sides_colored = "(homedecor_generic_wood_plain.png^[transformR90)^homedecor_kitchen_cabinet_bevel.png" diff --git a/homedecor_laundry/init.lua b/homedecor_laundry/init.lua index 084bce11..96508220 100644 --- a/homedecor_laundry/init.lua +++ b/homedecor_laundry/init.lua @@ -80,8 +80,7 @@ local ib_cbox = { fixed = { -6/16, -8/16, -4/16, 17/16, 4/16, 4/16 } } -local wool_tex = "wool_grey.png" -if not minetest.get_modpath("wool") then wool_tex = "[combine:16x16^[noalpha^[colorize:#3A3B3C" end +local wool_tex = homedecor.textures.wool.grey homedecor.register("ironing_board", { description = S("Ironing board"), diff --git a/homedecor_lighting/init.lua b/homedecor_lighting/init.lua index f3e4073a..9fba9c62 100644 --- a/homedecor_lighting/init.lua +++ b/homedecor_lighting/init.lua @@ -452,7 +452,7 @@ for brightness_level = 0, 14 do lighttex = "homedecor_plasma_lamp_off.png" end - local gtex=minetest.get_modpath("default") and "default_gold_block.png" or "[combine:16x16^[noalpha^[colorize:#FFD700" + local gtex=homedecor.textures.metal.gold.block homedecor.register("plasma_lamp_"..brightness_level, { description = S("Plasma Lamp/Light"), drawtype = "mesh", @@ -703,8 +703,7 @@ for brightness_level = 0, 14 do fixed = { -0.25, -0.5, -0.25, 0.25, 1.5, 0.25 } } - local wool_brightened=(minetest.get_modpath("wool") and "wool_grey.png" or "[combine:16x16^[noalpha6[colorize:#A9A9A9") - .. "^[colorize:#ffffff:"..(brightness_level * 15) + local wool_brightened=homedecor.textures.wool.grey .. "^[colorize:#ffffff:"..(brightness_level * 15) homedecor.register("table_lamp_"..brightness_level, { description = S("Table Lamp/Light"), diff --git a/homedecor_misc/init.lua b/homedecor_misc/init.lua index eef97490..f16413d8 100644 --- a/homedecor_misc/init.lua +++ b/homedecor_misc/init.lua @@ -11,8 +11,8 @@ local S = minetest.get_translator("homedecor_misc") homedecor_misc = {} -local wool_black, wool_grey = homedecor.textures.wool_black, homedecor.textures.wool_grey -local wood_tex = homedecor.textures.default_wood +local wool_black, wool_grey = homedecor.textures.wool.black, homedecor.textures.wool.grey +local wood_tex = homedecor.textures.wood.apple.planks homedecor.register("ceiling_paint", { description = S("Textured Ceiling Paint"), diff --git a/homedecor_pictures_and_paintings/init.lua b/homedecor_pictures_and_paintings/init.lua index d231cb3f..39c79c24 100644 --- a/homedecor_pictures_and_paintings/init.lua +++ b/homedecor_pictures_and_paintings/init.lua @@ -1,6 +1,6 @@ local S = minetest.get_translator("homedecor_pictures_and_paintings") -local wood_tex = homedecor.textures.default_wood +local wood_tex = homedecor.textures.wood.apple.planks local pframe_cbox = { type = "fixed", diff --git a/homedecor_roofing/init.lua b/homedecor_roofing/init.lua index 64f76383..123f12bd 100644 --- a/homedecor_roofing/init.lua +++ b/homedecor_roofing/init.lua @@ -5,8 +5,8 @@ homedecor_roofing = {} minetest.register_node(":homedecor:skylight", { description = S("Glass Skylight"), drawtype = "raillike", - tiles = { homedecor.textures.glass }, - wield_image = homedecor.textures.glass, + tiles = { homedecor.textures.glass.pane }, + wield_image = homedecor.textures.glass.pane, inventory_image = "homedecor_skylight_inv.png", groups = { snappy = 3, dig_tree = 2 , axey=5}, is_ground_content = false, @@ -336,8 +336,7 @@ homedecor_roofing.register_slope("homedecor", "glass", S("Glass Shingles") ) -local brick_tex = "default_brick.png" -if not minetest.get_modpath("default") then brick_tex = "[combine:16x16^[noalpha^[colorize:#AA4A44" end +local brick_tex = homedecor.textures.brick homedecor.register("chimney", { description = S("Chimney"), diff --git a/homedecor_seating/armchairs.lua b/homedecor_seating/armchairs.lua index 22c1c107..8359c913 100644 --- a/homedecor_seating/armchairs.lua +++ b/homedecor_seating/armchairs.lua @@ -40,9 +40,9 @@ homedecor.register("armchair", { description = S("Armchair"), mesh = "forniture_armchair.obj", tiles = { - homedecor.textures.wool_white, - { name = homedecor.textures.wool_dark_grey, color = 0xffffffff }, - { name = homedecor.textures.default_wood, color = 0xffffffff } + homedecor.textures.wool.white, + { name = homedecor.textures.wool.dark_grey, color = 0xffffffff }, + { name = homedecor.textures.wood.apple.planks, color = 0xffffffff } }, inventory_image = "homedecor_armchair_inv.png", paramtype2 = "colorwallmounted", diff --git a/homedecor_seating/misc.lua b/homedecor_seating/misc.lua index 41555faf..b5d9bb64 100644 --- a/homedecor_seating/misc.lua +++ b/homedecor_seating/misc.lua @@ -162,7 +162,7 @@ homedecor.register("kitchen_chair_padded", { mesh = "homedecor_kitchen_chair.obj", tiles = { homedecor.plain_wood, - homedecor.textures.wool_white, + homedecor.textures.wool.white, }, inventory_image = "homedecor_chair_padded_inv.png", paramtype2 = "colorwallmounted", diff --git a/homedecor_windows_and_treatments/init.lua b/homedecor_windows_and_treatments/init.lua index 04004b22..d65ff5a2 100644 --- a/homedecor_windows_and_treatments/init.lua +++ b/homedecor_windows_and_treatments/init.lua @@ -161,7 +161,7 @@ homedecor.register("curtain_open", { local mats = { { "brass", S("brass"), "homedecor_generic_metal_brass.png" }, { "wrought_iron", S("wrought iron"), "homedecor_generic_metal_wrought_iron.png" }, - { "wood", S("wood"), homedecor.textures.default_wood } + { "wood", S("wood"), homedecor.textures.wood.apple.planks } } for _, m in ipairs(mats) do