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
[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 = {}
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