]> git.lizzy.rs Git - signs_lib.git/blobdiff - api.lua
Locked Wood Signs
[signs_lib.git] / api.lua
diff --git a/api.lua b/api.lua
index e3238626585da097b041818a49147522e0384c4c..aad4d3610ce17ad2d3403b24133d78a2cfcef729 100644 (file)
--- a/api.lua
+++ b/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
@@ -31,6 +30,11 @@ signs_lib.standard_steel_sign_sounds = table.copy(minetest.registered_items["def
 
 signs_lib.default_text_scale = {x=10, y=10}
 
+signs_lib.old_widefont_signs = {}
+
+signs_lib.block_list = {}
+signs_lib.totalblocks = 0
+
 signs_lib.standard_yaw = {
        0,
        math.pi / -2,
@@ -155,7 +159,7 @@ local ctexcache = {}
 minetest.register_entity("signs_lib:text", {
        collisionbox = { 0, 0, 0, 0, 0, 0 },
        visual = "mesh",
-       mesh = "signs_lib_standard_wall_sign_entity.obj",
+       mesh = "signs_lib_standard_sign_entity_wall.obj",
        textures = {},
        static_save = false,
        backface_culling = false
@@ -164,7 +168,12 @@ minetest.register_entity("signs_lib:text", {
 function signs_lib.delete_objects(pos)
        local objects = minetest.get_objects_inside_radius(pos, 0.5)
        for _, v in ipairs(objects) do
-               v:remove()
+               if v then
+                       local e = v:get_luaentity()
+                       if e and string.match(e.name, "sign.*text") then
+                               v:remove()
+                       end
+               end
        end
 end
 
@@ -178,8 +187,17 @@ function signs_lib.spawn_entity(pos, texture)
        local obj
 
        if #objects > 0 then
-               obj = objects[1]
-       else
+               for _, v in ipairs(objects) do
+                       if v then
+                               local e = v:get_luaentity()
+                               if e and e.name == "signs_lib:text" then
+                                       obj = v
+                               end
+                       end
+               end
+       end
+
+       if not obj then
                obj = minetest.add_entity(pos, "signs_lib:text")
        end
 
@@ -226,6 +244,14 @@ function signs_lib.spawn_entity(pos, texture)
        end
 end
 
+function signs_lib.set_obj_text(pos, text)
+       local split = signs_lib.split_lines_and_words
+       local text_ansi = Utf8ToAnsi(text)
+       local n = minetest.registered_nodes[minetest.get_node(pos).name]
+       signs_lib.delete_objects(pos)
+       signs_lib.spawn_entity(pos, signs_lib.make_sign_texture(split(text_ansi), pos) )
+end
+
 -- rotation
 
 function signs_lib.handle_rotation(pos, node, user, mode)
@@ -284,7 +310,6 @@ function signs_lib.handle_rotation(pos, node, user, mode)
                minetest.swap_node(tpos, { name = node.name, param2 = signs_lib.rotate_facedir[node.param2] or 0 })
        end
 
-       signs_lib.delete_objects(tpos)
        signs_lib.update_sign(tpos)
        return true
 end
@@ -540,8 +565,10 @@ local function make_line_texture(line, lineno, pos, line_width, line_height, cwi
        return table.concat(texture), lineno
 end
 
-local function make_sign_texture(lines, pos)
+function signs_lib.make_sign_texture(lines, pos)
        local node = minetest.get_node(pos)
+       local meta = minetest.get_meta(pos)
+
        local def = minetest.registered_items[node.name]
        if not def or not def.entity_info then return end
 
@@ -550,16 +577,21 @@ local function make_sign_texture(lines, pos)
        local line_height
        local char_width
        local colorbgw
+       local widemult = 1
+
+       if meta:get_int("widefont") == 1 then
+               widemult = 0.5
+       end
 
        if def.font_size and def.font_size == 31 then
                font_size = 31
-               line_width = math.floor(signs_lib.avgwidth31 * def.chars_per_line) * def.horiz_scaling
+               line_width = math.floor(signs_lib.avgwidth31 * def.chars_per_line) * (def.horiz_scaling * widemult)
                line_height = signs_lib.lineheight31
                char_width = signs_lib.charwidth31
                colorbgw = signs_lib.colorbgw31
        else
                font_size = 15
-               line_width = math.floor(signs_lib.avgwidth15 * def.chars_per_line) * def.horiz_scaling
+               line_width = math.floor(signs_lib.avgwidth15 * def.chars_per_line) * (def.horiz_scaling * widemult)
                line_height = signs_lib.lineheight15
                char_width = signs_lib.charwidth15
                colorbgw = signs_lib.colorbgw15
@@ -581,45 +613,23 @@ end
 function signs_lib.split_lines_and_words(text)
        if not text then return end
        local lines = { }
-       for _, line in ipairs(text:split("\n")) do
+       for _, line in ipairs(text:split("\n", true)) do
                table.insert(lines, line:split(" "))
        end
        return lines
 end
 
-function signs_lib.set_obj_text(pos, text)
-       local split = signs_lib.split_lines_and_words
-       local text_ansi = Utf8ToAnsi(text)
-       local n = minetest.registered_nodes[minetest.get_node(pos).name]
-       signs_lib.delete_objects(pos)
-       signs_lib.spawn_entity(pos, make_sign_texture(split(text_ansi), pos))
-end
-
-local function make_widefont_nodename(name)
-       if string.find(name, "_widefont") then return name end
-       if string.find(name, "_onpole")  then
-               if string.find(name, "_horiz") then
-                       return string.gsub(name, "_onpole_horiz", "_widefont_onpole_horiz")
-               else
-                       return string.gsub(name, "_onpole", "_widefont_onpole")
-               end
-       elseif string.find(name, "_hanging") then
-               return string.gsub(name, "_hanging", "_widefont_hanging")
-       else
-               return name.."_widefont"
-       end
-end
-
 function signs_lib.construct_sign(pos)
        local form = "size[6,4]"..
                "textarea[0,-0.3;6.5,3;text;;${text}]"..
                "background[-0.5,-0.5;7,5;signs_lib_sign_bg.jpg]"
        local node = minetest.get_node(pos)
-       local wname = make_widefont_nodename(node.name)
+       local def = minetest.registered_items[node.name]
+       local meta = minetest.get_meta(pos)
 
-       if minetest.registered_items[wname] then
+       if def.allow_widefont then
                local state = "off"
-               if string.find(node.name, "widefont") then state = "on" end
+               if meta:get_int("widefont") == 1 then state = "on" end
                form = form.."label[1,3.4;Use wide font]"..
                        "image_button[1.1,3.7;1,0.6;signs_lib_switch_"..
                        state..".png;"..
@@ -629,7 +639,6 @@ function signs_lib.construct_sign(pos)
                form = form.."button_exit[2,3.4;2,1;ok;"..S("Write").."]"
        end
 
-       local meta = minetest.get_meta(pos)
        meta:set_string("formspec", form)
        local i = meta:get_string("infotext")
        if i == "" then -- it wasn't even set, so set it.
@@ -679,21 +688,22 @@ function signs_lib.receive_fields(pos, formname, fields, sender)
                signs_lib.update_sign(pos, fields)
        elseif fields.on or fields.off then
                local node = minetest.get_node(pos)
-               local newname
-
-               if fields.on and string.find(node.name, "widefont") then
-                       newname = string.gsub(node.name, "_widefont", "")
-               elseif fields.off and not string.find(node.name, "widefont") then
-                       newname = make_widefont_nodename(node.name)
+               local meta = minetest.get_meta(pos)
+               local change
+
+               if fields.on and meta:get_int("widefont") == 1 then
+                       meta:set_int("widefont", 0)
+                       change = true
+               elseif fields.off and meta:get_int("widefont") == 0 then
+                       meta:set_int("widefont", 1)
+                       change = true
                end
-               if newname then
+               if change then
                        minetest.log("action", S("@1 flipped the wide-font switch to \"@2\" at @3",
                                (sender:get_player_name() or ""),
                                (fields.on and "off" or "on"),
                                minetest.pos_to_string(pos)
                        ))
-
-                       minetest.swap_node(pos, {name = newname, param2 = node.param2})
                        signs_lib.construct_sign(pos)
                        signs_lib.update_sign(pos, fields)
                end
@@ -751,36 +761,39 @@ function signs_lib.check_for_pole(pos, 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 signs_lib.check_for_ceiling(pointed_thing) or signs_lib.check_for_floor(pointed_thing) then
+               return false
+       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
        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" then
-               if def.paramtype2 == "wallmounted" then
-                       if   ((node.param2 == 2 or node.param2 == 3) and (pnode.param2 > 3 and pnode.param2 < 12)) -- E/W
-                         or ((node.param2 == 4 or node.param2 == 5) and (pnode.param2 > 11 and pnode.param2 < 20)) -- N/S
-                               then return true
-                       end
-               else
-                       if   ((node.param2 == 1 or node.param2 == 3) and (pnode.param2 > 3 and pnode.param2 < 12)) -- E/W
-                         or ((node.param2 == 0 or node.param2 == 2) and (pnode.param2 > 11 and pnode.param2 < 20)) -- N/S
-                               then return true
-                       end
-               end
+       local pdef = minetest.registered_items[pnode.name]
+
+       if not pdef then return end
+
+       if signs_lib.check_for_ceiling(pointed_thing) or signs_lib.check_for_floor(pointed_thing) then
+               return false
+       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)
        end
 end
 
@@ -802,12 +815,19 @@ end
 
 function signs_lib.after_place_node(pos, placer, itemstack, pointed_thing, locked)
        local playername = placer:get_player_name()
-       local def = minetest.registered_items[itemstack:get_name()]
+
+       local controls = placer:get_player_control()
+
+       local signname = itemstack:get_name()
+       local no_wall_name = string.gsub(signname, "_wall", "")
+
+       local def = minetest.registered_items[signname]
 
        local ppos = minetest.get_pointed_thing_position(pointed_thing)
        local pnode = minetest.get_node(ppos)
        local pdef = minetest.registered_items[pnode.name]
-       if (def.allow_onpole ~= false) and signs_lib.check_for_pole(pos, pointed_thing) then
+
+       if def.allow_onpole and signs_lib.check_for_pole(pos, pointed_thing) and not controls.sneak then
                local newparam2
                local lookdir = minetest.yaw_to_dir(placer:get_look_horizontal())
                if def.paramtype2 == "wallmounted" then
@@ -816,8 +836,8 @@ function signs_lib.after_place_node(pos, placer, itemstack, pointed_thing, locke
                        newparam2 = minetest.dir_to_facedir(lookdir)
                end
                local node = minetest.get_node(pos)
-               minetest.swap_node(pos, {name = itemstack:get_name().."_onpole", param2 = newparam2})
-       elseif def.allow_onpole_horizontal and signs_lib.check_for_horizontal_pole(pos, pointed_thing) then
+               minetest.swap_node(pos, {name = no_wall_name.."_onpole", param2 = newparam2})
+       elseif def.allow_onpole_horizontal and signs_lib.check_for_horizontal_pole(pos, pointed_thing) and not controls.sneak then
                local newparam2
                local lookdir = minetest.yaw_to_dir(placer:get_look_horizontal())
                if def.paramtype2 == "wallmounted" then
@@ -826,16 +846,21 @@ function signs_lib.after_place_node(pos, placer, itemstack, pointed_thing, locke
                        newparam2 = minetest.dir_to_facedir(lookdir)
                end
                local node = minetest.get_node(pos)
-               minetest.swap_node(pos, {name = itemstack:get_name().."_onpole_horiz", param2 = newparam2})
-       elseif def.allow_hanging and signs_lib.check_for_ceiling(pointed_thing) then
+               minetest.swap_node(pos, {name = no_wall_name.."_onpole_horiz", param2 = newparam2})
+       elseif def.allow_hanging and signs_lib.check_for_ceiling(pointed_thing) and not controls.sneak then
                local newparam2 = minetest.dir_to_facedir(placer:get_look_dir())
                local node = minetest.get_node(pos)
-               minetest.swap_node(pos, {name = itemstack:get_name().."_hanging", param2 = newparam2})
+               minetest.swap_node(pos, {name = no_wall_name.."_hanging", param2 = newparam2})
+       elseif def.allow_yard and signs_lib.check_for_floor(pointed_thing) and not controls.sneak then
+               local newparam2 = minetest.dir_to_facedir(placer:get_look_dir())
+               local node = minetest.get_node(pos)
+               minetest.swap_node(pos, {name = no_wall_name.."_yard", param2 = newparam2})
        elseif def.paramtype2 == "facedir" and signs_lib.check_for_ceiling(pointed_thing) then
-               minetest.swap_node(pos, {name = itemstack:get_name(), param2 = 6})
+               minetest.swap_node(pos, {name = signname, param2 = 6})
        elseif def.paramtype2 == "facedir" and signs_lib.check_for_floor(pointed_thing) then
-               minetest.swap_node(pos, {name = itemstack:get_name(), param2 = 4})
+               minetest.swap_node(pos, {name = signname, param2 = 4})
        end
+
        if locked then
                local meta = minetest.get_meta(pos)
                meta:set_string("owner", playername)
@@ -847,195 +872,194 @@ function signs_lib.register_fence_with_sign()
        minetest.log("warning", "[signs_lib] ".."Attempt to call no longer used function signs_lib.register_fence_with_sign()")
 end
 
-local function register_sign(name, rdef)
-       local def = table.copy(rdef)
+function signs_lib.register_sign(name, raw_def)
+       local def = table.copy(raw_def)
 
-       if rdef.entity_info == "standard" then
+       if raw_def.entity_info == "standard" then
                def.entity_info = {
-                       mesh = "signs_lib_standard_wall_sign_entity.obj",
+                       mesh = "signs_lib_standard_sign_entity_wall.obj",
                        yaw = signs_lib.wallmounted_yaw
                }
-       elseif rdef.entity_info then
-               def.entity_info = rdef.entity_info
+       elseif raw_def.entity_info then
+               def.entity_info = raw_def.entity_info
        end
 
-       def.after_place_node = rdef.after_place_node or signs_lib.after_place_node
-
-       if rdef.entity_info then
-               def.on_rightclick       = rdef.on_rightclick       or signs_lib.construct_sign
-               def.on_construct        = rdef.on_construct        or signs_lib.construct_sign
-               def.on_destruct         = rdef.on_destruct         or signs_lib.destruct_sign
-               def.on_receive_fields   = rdef.on_receive_fields   or signs_lib.receive_fields
-               def.on_punch            = rdef.on_punch            or signs_lib.update_sign
-               def.number_of_lines     = rdef.number_of_lines     or signs_lib.standard_lines
-               def.horiz_scaling       = rdef.horiz_scaling       or signs_lib.standard_hscale
-               def.vert_scaling        = rdef.vert_scaling        or signs_lib.standard_vscale
-               def.line_spacing        = rdef.line_spacing        or signs_lib.standard_lspace
-               def.font_size           = rdef.font_size           or signs_lib.standard_fsize
-               def.x_offset            = rdef.x_offset            or signs_lib.standard_xoffs
-               def.y_offset            = rdef.y_offset            or signs_lib.standard_yoffs
-               def.chars_per_line      = rdef.chars_per_line      or signs_lib.standard_cpl
-               def.default_color       = rdef.default_color       or "0"
-               if rdef.locked and not rdef.after_place_node then
+       def.after_place_node = raw_def.after_place_node or signs_lib.after_place_node
+
+       if raw_def.entity_info then
+               def.on_rightclick       = raw_def.on_rightclick       or signs_lib.construct_sign
+               def.on_construct        = raw_def.on_construct        or signs_lib.construct_sign
+               def.on_destruct         = raw_def.on_destruct         or signs_lib.destruct_sign
+               def.on_receive_fields   = raw_def.on_receive_fields   or signs_lib.receive_fields
+               def.on_punch            = raw_def.on_punch            or signs_lib.update_sign
+               def.number_of_lines     = raw_def.number_of_lines     or signs_lib.standard_lines
+               def.horiz_scaling       = raw_def.horiz_scaling       or signs_lib.standard_hscale
+               def.vert_scaling        = raw_def.vert_scaling        or signs_lib.standard_vscale
+               def.line_spacing        = raw_def.line_spacing        or signs_lib.standard_lspace
+               def.font_size           = raw_def.font_size           or signs_lib.standard_fsize
+               def.x_offset            = raw_def.x_offset            or signs_lib.standard_xoffs
+               def.y_offset            = raw_def.y_offset            or signs_lib.standard_yoffs
+               def.chars_per_line      = raw_def.chars_per_line      or signs_lib.standard_cpl
+               def.default_color       = raw_def.default_color       or "0"
+               if raw_def.locked and not raw_def.after_place_node then
                        def.after_place_node = function(pos, placer, itemstack, pointed_thing)
                                signs_lib.after_place_node(pos, placer, itemstack, pointed_thing, true)
                        end
                end
        end
 
-       def.paramtype           = rdef.paramtype           or "light"
-       def.drawtype            = rdef.drawtype            or "mesh"
-       def.mesh                = rdef.mesh                or "signs_lib_standard_wall_sign.obj"
-       def.wield_image         = rdef.wield_image         or def.inventory_image
-       def.drop                = rdef.drop                or name
-       def.sounds              = rdef.sounds              or signs_lib.standard_wood_sign_sounds
-       def.paramtype2          = rdef.paramtype2          or "wallmounted"
-       def.on_rotate           = rdef.on_rotate           or signs_lib.handle_rotation
-
-       if rdef.groups then
-               def.groups = rdef.groups
+       def.paramtype           = raw_def.paramtype           or "light"
+       def.drawtype            = raw_def.drawtype            or "mesh"
+       def.mesh                = raw_def.mesh                or "signs_lib_standard_sign_wall.obj"
+       def.wield_image         = raw_def.wield_image         or def.inventory_image
+       def.drop                = raw_def.drop                or name
+       def.sounds              = raw_def.sounds              or signs_lib.standard_wood_sign_sounds
+       def.paramtype2          = raw_def.paramtype2          or "wallmounted"
+       def.on_rotate           = raw_def.on_rotate           or signs_lib.handle_rotation
+
+       if raw_def.groups then
+               def.groups = raw_def.groups
        else
                def.groups = signs_lib.standard_wood_groups
        end
 
        local cbox = signs_lib.make_selection_boxes(35, 25)
 
-       def.selection_box = rdef.selection_box or cbox
-       def.node_box      = table.copy(rdef.node_box or rdef.selection_box or cbox)
+       def.selection_box = raw_def.selection_box or cbox
+       def.node_box      = table.copy(raw_def.node_box or raw_def.selection_box or cbox)
 
        if def.sunlight_propagates ~= false then
                def.sunlight_propagates = true
        end
 
+       def.tiles[3] = "signs_lib_blank.png"
+       def.tiles[4] = "signs_lib_blank.png"
+       def.tiles[5] = "signs_lib_blank.png"
+       def.tiles[6] = "signs_lib_blank.png"
+
        minetest.register_node(":"..name, def)
        table.insert(signs_lib.lbm_restore_nodes, name)
 
-       local opdef = table.copy(def)
+       local no_wall_name = string.gsub(name, "_wall", "")
+
+       local othermounts_def = table.copy(def)
 
-       if rdef.allow_onpole ~= false or rdef.allow_onpole_horizontal then
+       if raw_def.allow_onpole or raw_def.allow_onpole_horizontal then
 
                local offset = 0.3125
-               if opdef.uses_slim_pole_mount then
+               if othermounts_def.uses_slim_pole_mount then
                        offset = 0.35
                end
 
-               opdef.selection_box = rdef.onpole_selection_box or opdef.selection_box
-               opdef.node_box = rdef.onpole_node_box or opdef.selection_box
+               othermounts_def.selection_box = raw_def.onpole_selection_box or othermounts_def.selection_box
+               othermounts_def.node_box = raw_def.onpole_node_box or othermounts_def.selection_box
 
-               if opdef.paramtype2 == "wallmounted" then
-                       opdef.node_box.wall_side[1] = def.node_box.wall_side[1] - offset
-                       opdef.node_box.wall_side[4] = def.node_box.wall_side[4] - offset
+               if othermounts_def.paramtype2 == "wallmounted" then
+                       othermounts_def.node_box.wall_side[1] = def.node_box.wall_side[1] - offset
+                       othermounts_def.node_box.wall_side[4] = def.node_box.wall_side[4] - offset
 
-                       opdef.selection_box.wall_side[1] = def.selection_box.wall_side[1] - offset
-                       opdef.selection_box.wall_side[4] = def.selection_box.wall_side[4] - offset
+                       othermounts_def.selection_box.wall_side[1] = def.selection_box.wall_side[1] - offset
+                       othermounts_def.selection_box.wall_side[4] = def.selection_box.wall_side[4] - offset
                else
-                       opdef.node_box.fixed[3] = def.node_box.fixed[3] + offset
-                       opdef.node_box.fixed[6] = def.node_box.fixed[6] + offset
+                       othermounts_def.node_box.fixed[3] = def.node_box.fixed[3] + offset
+                       othermounts_def.node_box.fixed[6] = def.node_box.fixed[6] + offset
 
-                       opdef.selection_box.fixed[3] = def.selection_box.fixed[3] + offset
-                       opdef.selection_box.fixed[6] = def.selection_box.fixed[6] + offset
+                       othermounts_def.selection_box.fixed[3] = def.selection_box.fixed[3] + offset
+                       othermounts_def.selection_box.fixed[6] = def.selection_box.fixed[6] + offset
                end
 
-               opdef.groups.not_in_creative_inventory = 1
-               opdef.mesh = string.gsub(opdef.mesh, ".obj$", "_onpole.obj")
+               othermounts_def.groups.not_in_creative_inventory = 1
+               othermounts_def.mesh = raw_def.onpole_mesh or string.gsub(othermounts_def.mesh, "wall.obj$", "onpole.obj")
 
-               if opdef.entity_info then
-                       opdef.entity_info.mesh = string.gsub(opdef.entity_info.mesh, ".obj$", "_onpole.obj")
+               if othermounts_def.entity_info then
+                       othermounts_def.entity_info.mesh = string.gsub(othermounts_def.entity_info.mesh, "entity_wall.obj$", "entity_onpole.obj")
                end
        end
 
        -- setting one of item 3 or 4 to a texture and leaving the other "blank",
        -- reveals either the vertical or horizontal pole mount part of the model
 
-       if rdef.allow_onpole ~= false then
-               opdef.tiles[3] = "signs_lib_pole_mount.png"
-               opdef.tiles[4] = "signs_lib_blank.png"
-               minetest.register_node(":"..name.."_onpole", opdef)
-               table.insert(signs_lib.lbm_restore_nodes, name.."_onpole")
+       if raw_def.allow_onpole then
+               othermounts_def.tiles[3] = raw_def.tiles[3] or "signs_lib_pole_mount.png"
+               othermounts_def.tiles[4] = "signs_lib_blank.png"
+               othermounts_def.tiles[5] = "signs_lib_blank.png"
+               othermounts_def.tiles[6] = "signs_lib_blank.png"
+
+               minetest.register_node(":"..no_wall_name.."_onpole", othermounts_def)
+               table.insert(signs_lib.lbm_restore_nodes, no_wall_name.."_onpole")
        end
 
-       local ophdef = table.copy(opdef)
+       if raw_def.allow_onpole_horizontal then
+               local onpole_horiz_def = table.copy(othermounts_def)
 
-       if rdef.allow_onpole_horizontal then
-               ophdef.tiles[3] = "signs_lib_blank.png"
-               ophdef.tiles[4] = "signs_lib_pole_mount.png"
-               minetest.register_node(":"..name.."_onpole_horiz", ophdef)
-               table.insert(signs_lib.lbm_restore_nodes, name.."_onpole_horiz")
+               onpole_horiz_def.tiles[3] = "signs_lib_blank.png"
+               onpole_horiz_def.tiles[4] = raw_def.tiles[3] or "signs_lib_pole_mount.png"
+               onpole_horiz_def.tiles[5] = "signs_lib_blank.png"
+               onpole_horiz_def.tiles[6] = "signs_lib_blank.png"
+
+               minetest.register_node(":"..no_wall_name.."_onpole_horiz", onpole_horiz_def)
+               table.insert(signs_lib.lbm_restore_nodes, no_wall_name.."_onpole_horiz")
        end
 
-       if rdef.allow_hanging then
+       if raw_def.allow_hanging then
 
-               local hdef = table.copy(def)
-               hdef.paramtype2 = "facedir"
+               local hanging_def = table.copy(def)
+               hanging_def.paramtype2 = "facedir"
 
                local hcbox = signs_lib.make_selection_boxes(35, 32, nil, 0, 3, -18.5, true)
 
-               hdef.selection_box = rdef.hanging_selection_box or hcbox
-               hdef.node_box = rdef.hanging_node_box or rdef.hanging_selection_box or hcbox
+               hanging_def.selection_box = raw_def.hanging_selection_box or hcbox
+               hanging_def.node_box = raw_def.hanging_node_box or raw_def.hanging_selection_box or hcbox
+
+               hanging_def.groups.not_in_creative_inventory = 1
+               hanging_def.tiles[3] = raw_def.tiles[4] or "signs_lib_hangers.png"
+               hanging_def.tiles[4] = "signs_lib_blank.png"
+               hanging_def.tiles[5] = "signs_lib_blank.png"
+               hanging_def.tiles[6] = "signs_lib_blank.png"
 
-               hdef.groups.not_in_creative_inventory = 1
-               hdef.tiles[3] = "signs_lib_hangers.png"
-               hdef.mesh = string.gsub(string.gsub(hdef.mesh, "_facedir.obj", ".obj"), ".obj$", "_hanging.obj")
+               hanging_def.mesh = raw_def.hanging_mesh or string.gsub(string.gsub(hanging_def.mesh, "wall.obj$", "hanging.obj"), "_facedir", "")
 
-               if hdef.entity_info then
-                       hdef.entity_info.mesh = string.gsub(string.gsub(hdef.entity_info.mesh, "_facedir.obj", ".obj"), ".obj$", "_hanging.obj")
-                       hdef.entity_info.yaw = signs_lib.standard_yaw
+               if hanging_def.entity_info then
+                       hanging_def.entity_info.mesh = string.gsub(string.gsub(hanging_def.entity_info.mesh, "entity_wall.obj$", "entity_hanging.obj"), "_facedir", "")
+                       hanging_def.entity_info.yaw = signs_lib.standard_yaw
                end
 
-               minetest.register_node(":"..name.."_hanging", hdef)
-               table.insert(signs_lib.lbm_restore_nodes, name.."_hanging")
+               minetest.register_node(":"..no_wall_name.."_hanging", hanging_def)
+               table.insert(signs_lib.lbm_restore_nodes, no_wall_name.."_hanging")
        end
-end
-
---[[
-The main sign registration function
-===================================
-
-Example minimal recommended def for writable signs:
-
-signs_lib.register_sign("foo:my_cool_sign", {
-       description = "Wooden cool sign",
-       inventory_image = "signs_lib_sign_cool_inv.png",
-       tiles = {
-               "signs_lib_sign_cool.png",
-               "signs_lib_sign_cool_edges.png"
-       },
-       number_of_lines = 2,
-       horiz_scaling = 0.8,
-       vert_scaling = 1,
-       line_spacing = 9,
-       font_size = 31,
-       x_offset = 7,
-       y_offset = 4,
-       chars_per_line = 40,
-       entity_info = "standard"
-})
 
-* default def assumes a wallmounted sign with on-pole being allowed.
+       if raw_def.allow_yard then
 
-*For signs that can't support onpole, include in the def:
-       allow_onpole = false,
+               local ydef = table.copy(def)
+               ydef.paramtype2 = "facedir"
 
-* "standard" entity info implies the standard wood/steel sign model, in
-  wallmounted mode.  For facedir signs using the standard model, use:
+               local ycbox = signs_lib.make_selection_boxes(35, 34.5, false, 0, -1.25, -19.69, true)
 
-       entity_info = {
-               mesh = "signs_lib_standard_wall_sign_entity.obj",
-               yaw = signs_lib.standard_yaw
-       },
+               ydef.selection_box = raw_def.yard_selection_box or ycbox
+               ydef.tiles[3] = raw_def.tiles[5] or "default_wood.png"
+               ydef.tiles[4] = "signs_lib_blank.png"
+               ydef.tiles[5] = "signs_lib_blank.png"
+               ydef.tiles[6] = "signs_lib_blank.png"
 
-]]--
+               ydef.node_box = raw_def.yard_node_box or raw_def.yard_selection_box or ycbox
 
-function signs_lib.register_sign(name, rdef)
-       register_sign(name, rdef)
+               ydef.groups.not_in_creative_inventory = 1
+               ydef.mesh = raw_def.yard_mesh or string.gsub(string.gsub(ydef.mesh, "wall.obj$", "yard.obj"), "_facedir", "")
 
-       if rdef.allow_widefont then
+               if ydef.entity_info then
+                       ydef.entity_info.mesh = string.gsub(string.gsub(ydef.entity_info.mesh, "entity_wall.obj$", "entity_yard.obj"), "_facedir", "")
+                       ydef.entity_info.yaw = signs_lib.standard_yaw
+               end
 
-               local wdef = table.copy(minetest.registered_items[name])
-               wdef.groups.not_in_creative_inventory = 1
-               wdef.horiz_scaling = wdef.horiz_scaling / 2
+               minetest.register_node(":"..no_wall_name.."_yard", ydef)
+               table.insert(signs_lib.lbm_restore_nodes, no_wall_name.."_yard")
+       end
 
-               register_sign(name.."_widefont", wdef)
+       if raw_def.allow_widefont then
+               table.insert(signs_lib.old_widefont_signs, name.."_widefont")
+               table.insert(signs_lib.old_widefont_signs, name.."_widefont_onpole")
+               table.insert(signs_lib.old_widefont_signs, name.."_widefont_hanging")
+               table.insert(signs_lib.old_widefont_signs, name.."_widefont_yard")
        end
 end
 
@@ -1085,8 +1109,21 @@ minetest.register_lbm({
        end
 })
 
-signs_lib.block_list = {}
-signs_lib.totalblocks = 0
+-- Convert widefont sign nodes to use one base node with meta flag to select wide mode
+
+minetest.register_lbm({
+       nodenames = signs_lib.old_widefont_signs,
+       name = "signs_lib:convert_widefont_signs",
+       label = "Convert widefont sign nodes",
+       run_at_every_load = false,
+       action = function(pos, node)
+               local basename = string.gsub(node.name, "_widefont", "")
+               minetest.swap_node(pos, {name = basename, param2 = node.param2})
+               local meta = minetest.get_meta(pos)
+               meta:set_int("widefont", 1)
+               signs_lib.update_sign(pos)
+       end
+})
 
 -- Maintain a list of currently-loaded blocks
 minetest.register_lbm({