diff --git a/coloredwood/init.lua b/coloredwood/init.lua index b79285af..54aa708d 100644 --- a/coloredwood/init.lua +++ b/coloredwood/init.lua @@ -222,7 +222,9 @@ unifieddyes.register_color_craft({ }) if minetest.get_modpath("signs_lib") then - signs_lib.allowed_poles["coloredwood:fence"] = true + minetest.override_item("coloredwood:fence", { + check_for_pole = true + }) end print("[Colored Wood] Loaded!") diff --git a/gloopblocks/init.lua b/gloopblocks/init.lua index 15d6ecd0..570235d0 100644 --- a/gloopblocks/init.lua +++ b/gloopblocks/init.lua @@ -198,7 +198,8 @@ if not minetest.get_modpath("usesdirt") then wield_image = "default_fence_overlay.png^("..dirt_brick_tex..")^default_fence_overlay.png^[makealpha:255,126,126", material = "usesdirt:dirt_brick", groups = {cracky=3, stone=2}, - sounds = default.node_sound_stone_defaults() + sounds = default.node_sound_stone_defaults(), + check_for_pole = true }) if minetest.get_modpath("moreblocks") then @@ -256,7 +257,8 @@ if not minetest.get_modpath("usesdirt") then wield_image = "default_fence_overlay.png^default_dirt.png^default_fence_overlay.png^[makealpha:255,126,126", material = "default:dirt", groups = {snappy=2,choppy=1,oddly_breakable_by_hand=3}, - sounds = default.node_sound_dirt_defaults() + sounds = default.node_sound_dirt_defaults(), + check_for_pole = true }) ---- @@ -312,7 +314,8 @@ if not minetest.get_modpath("usesdirt") then wield_image = "default_fence_overlay.png^("..dirt_cobble_tex..")^default_fence_overlay.png^[makealpha:255,126,126", material = "usesdirt:dirt_cobble_stone", groups = {cracky=3, stone=2}, - sounds = default.node_sound_stone_defaults() + sounds = default.node_sound_stone_defaults(), + check_for_pole = true }) ---- @@ -360,16 +363,9 @@ if not minetest.get_modpath("usesdirt") then wield_image = "default_fence_overlay.png^("..dirt_stone_tex..")^default_fence_overlay.png^[makealpha:255,126,126", material = "usesdirt:dirt_stone", groups = {cracky=3, stone=2}, - sounds = default.node_sound_stone_defaults() + sounds = default.node_sound_stone_defaults(), + check_for_pole = true }) - - if minetest.get_modpath("signs_lib") then - signs_lib.allowed_poles["usesdirt:dirt_brick_fence"] = true - signs_lib.allowed_poles["usesdirt:dirt_fence"] = true - signs_lib.allowed_poles["usesdirt:dirt_cobble_stone_fence"] = true - signs_lib.allowed_poles["usesdirt:dirt_stone_fence"] = true - signs_lib.allowed_poles["usesdirt:dirt_stone_fence"] = true - end end -- Stairs/slabs defs, conversion of normal -> mossy items diff --git a/homedecor_fences/depends.txt b/homedecor_fences/depends.txt index 99e96229..8505ec7c 100644 --- a/homedecor_fences/depends.txt +++ b/homedecor_fences/depends.txt @@ -2,4 +2,4 @@ homedecor_common default basic_materials dye -basic_signs? +signs_lib? diff --git a/homedecor_fences/init.lua b/homedecor_fences/init.lua index f1fcf1d0..72e5a5f6 100644 --- a/homedecor_fences/init.lua +++ b/homedecor_fences/init.lua @@ -264,7 +264,7 @@ homedecor.register("fence_wrought_iron_2_corner", { }) -- insert the old wood signs-on-metal-fences into signs_lib's conversion LBM -if minetest.get_modpath("basic_signs") then +if minetest.get_modpath("signs_lib") then table.insert(signs_lib.old_fenceposts_with_signs, "homedecor:fence_brass_with_sign") signs_lib.old_fenceposts["homedecor:fence_brass_with_sign"] = "homedecor:fence_brass" signs_lib.old_fenceposts_replacement_signs["homedecor:fence_brass_with_sign"] = "default:sign_wall_wood_onpole" @@ -272,8 +272,6 @@ if minetest.get_modpath("basic_signs") then table.insert(signs_lib.old_fenceposts_with_signs, "homedecor:fence_wrought_iron_with_sign") signs_lib.old_fenceposts["homedecor:fence_wrought_iron_with_sign"] = "homedecor:fence_wrought_iron" signs_lib.old_fenceposts_replacement_signs["homedecor:fence_wrought_iron_with_sign"] = "default:sign_wall_wood_onpole" - - signs_lib.allowed_poles["homedecor:pole_brass"] = true end -- crafting diff --git a/homedecor_misc/depends.txt b/homedecor_misc/depends.txt index 92ae6dc6..879b82b9 100644 --- a/homedecor_misc/depends.txt +++ b/homedecor_misc/depends.txt @@ -5,3 +5,4 @@ unifieddyes building_blocks? technic? bucket? +signs_lib? diff --git a/homedecor_misc/init.lua b/homedecor_misc/init.lua index 9c85b96f..f89f8234 100644 --- a/homedecor_misc/init.lua +++ b/homedecor_misc/init.lua @@ -130,21 +130,22 @@ for _, f in ipairs(flowers_list) do end homedecor.register("pole_brass", { - description = S("Brass Pole"), + description = S("Brass Pole"), mesh = "homedecor_round_pole.obj", - tiles = {"homedecor_generic_metal_brass.png^homedecor_generic_metal_lines_overlay.png",}, - inventory_image = "homedecor_pole_brass_inv.png", - wield_image = "homedecor_pole_brass_inv.png", - selection_box = { - type = "fixed", - fixed = { -0.125, -0.5, -0.125, 0.125, 0.5, 0.125 }, - }, - collision_box = { - type = "fixed", - fixed = { -0.125, -0.5, -0.125, 0.125, 0.5, 0.125 }, - }, - groups = {snappy=3}, - sounds = default.node_sound_wood_defaults(), + tiles = {"homedecor_generic_metal_brass.png^homedecor_generic_metal_lines_overlay.png",}, + inventory_image = "homedecor_pole_brass_inv.png", + wield_image = "homedecor_pole_brass_inv.png", + selection_box = { + type = "fixed", + fixed = { -0.125, -0.5, -0.125, 0.125, 0.5, 0.125 }, + }, + collision_box = { + type = "fixed", + fixed = { -0.125, -0.5, -0.125, 0.125, 0.5, 0.125 }, + }, + groups = {snappy=3}, + sounds = default.node_sound_wood_defaults(), + check_for_pole = true }) homedecor.register("pole_wrought_iron", { diff --git a/signs_lib/api.lua b/signs_lib/api.lua index 7414cec6..0119f75d 100644 --- a/signs_lib/api.lua +++ b/signs_lib/api.lua @@ -6,7 +6,6 @@ signs_lib.lbm_restore_nodes = {} signs_lib.old_fenceposts = {} signs_lib.old_fenceposts_replacement_signs = {} signs_lib.old_fenceposts_with_signs = {} -signs_lib.allowed_poles = {} -- Settings used for a standard wood or steel wall sign signs_lib.standard_lines = 6 @@ -152,78 +151,6 @@ signs_lib.flip_walldir = { [5] = 4 } -local htj_north = { - [1] = true, - [3] = true, - [9] = true, - [11] = true, - [21] = true, - [23] = true -} - -local htj_east = { - [0] = true, - [2] = true, - [16] = true, - [18] = true, - [20] = true, - [22] = true -} - -local htj_south = { - [1] = true, - [3] = true, - [5] = true, - [7] = true, - [21] = true, - [23] = true -} - -local htj_west = { - [0] = true, - [2] = true, - [12] = true, - [14] = true, - [20] = true, - [22] = true -} - -local vtj_north = { - [8] = true, - [10] = true, - [13] = true, - [15] = true, - [17] = true, - [19] = true -} - -local vtj_east = { - [4] = true, - [6] = true, - [8] = true, - [10] = true, - [17] = true, - [19] = true -} - -local vtj_south = { - [4] = true, - [6] = true, - [13] = true, - [15] = true, - [17] = true, - [10] = true -} - -local vtj_west = { - [4] = true, - [6] = true, - [8] = true, - [10] = true, - [13] = true, - [15] = true -} - -- Initialize character texture cache local ctexcache = {} @@ -817,83 +744,37 @@ function signs_lib.make_selection_boxes(sizex, sizey, foo, xoffs, yoffs, zoffs, end function signs_lib.check_for_pole(pos, pointed_thing) - local node = minetest.get_node(pos) - local def = minetest.registered_items[node.name] - local ppos = minetest.get_pointed_thing_position(pointed_thing) local pnode = minetest.get_node(ppos) local pdef = minetest.registered_items[pnode.name] - if (signs_lib.allowed_poles[pnode.name] - or (pdef and pdef.drawtype == "fencelike") - or string.find(pnode.name, "default:fence_") + if not pdef then return end + + if type(pdef.check_for_pole) == "function" then + local node = minetest.get_node(pos) + local def = minetest.registered_items[node.name] + return pdef.check_for_pole(pos, node, def, ppos, pnode, pdef) + elseif pdef.check_for_pole + or pdef.drawtype == "fencelike" or string.find(pnode.name, "_post") - or string.find(pnode.name, "fencepost") - or string.find(pnode.name, "streets:streetlamp_basic_top") - or (pnode.name == "streets:bigpole" and pnode.param2 < 4) - or (pnode.name == "streets:bigpole" and pnode.param2 > 19 and pnode.param2 < 24) ) - and (pos.x ~= ppos.x or pos.z ~= ppos.z) then + or string.find(pnode.name, "fencepost") then return true - elseif pnode.name == "streets:bigpole_tjunction" then - if def.paramtype2 == "wallmounted" then - if (node.param2 == 4 and vtj_north[pnode.param2]) - or (node.param2 == 2 and vtj_east[pnode.param2]) - or (node.param2 == 5 and vtj_south[pnode.param2]) - or (node.param2 == 3 and vtj_west[pnode.param2]) then - return true - end - else - if (node.param2 == 0 and vtj_north[pnode.param2]) - or (node.param2 == 1 and vtj_east[pnode.param2]) - or (node.param2 == 2 and vtj_south[pnode.param2]) - or (node.param2 == 3 and vtj_west[pnode.param2]) then - return true - end - end end end function signs_lib.check_for_horizontal_pole(pos, pointed_thing) - local node = minetest.get_node(pos) - local def = minetest.registered_items[node.name] local ppos = minetest.get_pointed_thing_position(pointed_thing) local pnode = minetest.get_node(ppos) - if pnode.name == "streets:bigpole" and pnode.param2 > 3 and pnode.param2 < 12 then - if def.paramtype2 == "wallmounted" then - if node.param2 == 2 or node.param2 == 3 -- E/W - then return true - end - else - if node.param2 == 1 or node.param2 == 3 -- E/W - then return true - end - end - elseif pnode.name == "streets:bigpole" and pnode.param2 > 11 and pnode.param2 < 20 then - if def.paramtype2 == "wallmounted" then - if node.param2 == 4 or node.param2 == 5 then - return true - end - else - if node.param2 == 0 or node.param2 == 2 then - return true - end - end - elseif pnode.name == "streets:bigpole_tjunction" then - if def.paramtype2 == "wallmounted" then - if (node.param2 == 4 and htj_north[pnode.param2]) - or (node.param2 == 2 and htj_east[pnode.param2]) - or (node.param2 == 5 and htj_south[pnode.param2]) - or (node.param2 == 3 and htj_west[pnode.param2]) then - return true - end - else - if (node.param2 == 0 and htj_north[pnode.param2]) - or (node.param2 == 1 and htj_east[pnode.param2]) - or (node.param2 == 2 and htj_south[pnode.param2]) - or (node.param2 == 3 and htj_west[pnode.param2]) then - return true - end - end + local pdef = minetest.registered_items[pnode.name] + + if not pdef then return end + + if type(pdef.check_for_horiz_pole) == "function" then + local node = minetest.get_node(pos) + local def = minetest.registered_items[node.name] + return pdef.check_for_horiz_pole(pos, node, def, ppos, pnode, pdef) + elseif pdef.check_for_horiz_pole then + return true end end diff --git a/signs_lib/compat.lua b/signs_lib/compat.lua new file mode 100644 index 00000000..76405d3e --- /dev/null +++ b/signs_lib/compat.lua @@ -0,0 +1,176 @@ + +local default_fences = { + "default:fence_wood", + "default:fence_acacia_wood", + "default:fence_aspen_wood", + "default:fence_junglewood", + "default:fence_pine_wood" +} + +for _, n in ipairs(default_fences) do + minetest.override_item(n, { + check_for_pole = true + }) +end + +if minetest.get_modpath("streetspoles") then + + local htj_north = { + [1] = true, + [3] = true, + [9] = true, + [11] = true, + [21] = true, + [23] = true + } + + local htj_east = { + [0] = true, + [2] = true, + [16] = true, + [18] = true, + [20] = true, + [22] = true + } + + local htj_south = { + [1] = true, + [3] = true, + [5] = true, + [7] = true, + [21] = true, + [23] = true + } + + local htj_west = { + [0] = true, + [2] = true, + [12] = true, + [14] = true, + [20] = true, + [22] = true + } + + local vtj_north = { + [8] = true, + [10] = true, + [13] = true, + [15] = true, + [17] = true, + [19] = true + } + + local vtj_east = { + [4] = true, + [6] = true, + [8] = true, + [10] = true, + [17] = true, + [19] = true + } + + local vtj_south = { + [4] = true, + [6] = true, + [13] = true, + [15] = true, + [17] = true, + [10] = true + } + + local vtj_west = { + [4] = true, + [6] = true, + [8] = true, + [10] = true, + [13] = true, + [15] = true + } + + minetest.override_item("streets:bigpole", { + check_for_pole = function(pos, node, def, ppos, pnode, pdef) + if pnode.param2 < 4 + or (pnode.param2 > 19 and pnode.param2 < 24) + and (pos.x ~= ppos.x or pos.z ~= ppos.z) then + return true + end + end, + + check_for_horiz_pole = function(pos, node, def, ppos, pnode, pdef) + if pnode.param2 > 3 and pnode.param2 < 12 then + if def.paramtype2 == "wallmounted" then + if node.param2 == 2 or node.param2 == 3 -- E/W + then return true + end + else + if node.param2 == 1 or node.param2 == 3 -- E/W + then return true + end + end + elseif pnode.param2 > 11 and pnode.param2 < 20 then + if def.paramtype2 == "wallmounted" then + if node.param2 == 4 or node.param2 == 5 then + return true + end + else + if node.param2 == 0 or node.param2 == 2 then + return true + end + end + end + end + }) + + minetest.override_item("streets:bigpole_tjunction", { + check_for_pole = function(pos, node, def, ppos, pnode, pdef) + if def.paramtype2 == "wallmounted" then + if (node.param2 == 4 and vtj_north[pnode.param2]) + or (node.param2 == 2 and vtj_east[pnode.param2]) + or (node.param2 == 5 and vtj_south[pnode.param2]) + or (node.param2 == 3 and vtj_west[pnode.param2]) then + return true + end + else + if (node.param2 == 0 and vtj_north[pnode.param2]) + or (node.param2 == 1 and vtj_east[pnode.param2]) + or (node.param2 == 2 and vtj_south[pnode.param2]) + or (node.param2 == 3 and vtj_west[pnode.param2]) then + return true + end + end + end, + + check_for_horiz_pole = function(pos, node, def, ppos, pnode, pdef) + if def.paramtype2 == "wallmounted" then + if (node.param2 == 4 and htj_north[pnode.param2]) + or (node.param2 == 2 and htj_east[pnode.param2]) + or (node.param2 == 5 and htj_south[pnode.param2]) + or (node.param2 == 3 and htj_west[pnode.param2]) then + return true + end + else + if (node.param2 == 0 and htj_north[pnode.param2]) + or (node.param2 == 1 and htj_east[pnode.param2]) + or (node.param2 == 2 and htj_south[pnode.param2]) + or (node.param2 == 3 and htj_west[pnode.param2]) then + return true + end + end + end + }) + +end + +if minetest.get_modpath("streetlamps") then + minetest.override_item("streets:streetlamp_basic_top_on", { + selection_box = { + type = "fixed", + fixed = { + {-0.3,-0.4,-0.3,0.3,0.5,0.3}, + {-0.15,-0.4,-0.15,0.15,-1.55,0.15}, + {-0.18,-1.55,-0.18,0.18,-2.5,0.18}, + } + }, + check_for_pole = true + }) +end diff --git a/signs_lib/depends.txt b/signs_lib/depends.txt index c0dd3b07..7e47df4a 100644 --- a/signs_lib/depends.txt +++ b/signs_lib/depends.txt @@ -1,3 +1,5 @@ default intllib? screwdriver? +streetspoles? +streetlamps? diff --git a/signs_lib/init.lua b/signs_lib/init.lua index 152cf1fd..fd6c8e75 100644 --- a/signs_lib/init.lua +++ b/signs_lib/init.lua @@ -13,3 +13,4 @@ signs_lib.gettext = S dofile(signs_lib.path.."/api.lua") dofile(signs_lib.path.."/encoding.lua") dofile(signs_lib.path.."/standard_signs.lua") +dofile(signs_lib.path.."/compat.lua")