From 58408a6f073b388fe93262a4b2a6fad5f8301c71 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Rollo Date: Sun, 10 Dec 2017 11:03:23 +0100 Subject: Added LBM to automatically update entities from signs:text to signs:display_text --- signs/compatibility.lua | 39 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 37 insertions(+), 2 deletions(-) (limited to 'signs') diff --git a/signs/compatibility.lua b/signs/compatibility.lua index 76bca89..3284230 100644 --- a/signs/compatibility.lua +++ b/signs/compatibility.lua @@ -20,6 +20,8 @@ -- Wallmounted to facedir conversion +------------------------------------ + local wallmounted_to_facedir = { [0]=1, -- Should not happend with signs [1]=1, -- Should not happend with signs @@ -36,7 +38,7 @@ local convert_nodes = { ['signs:poster'] = 'signs:paper_poster' } -local function compatibility_check(pos, node) +local function compatibility_check_1(pos, node) -- Old wallmounted modes to new facedir nodes conversion node.name = convert_nodes[node.name] if node.name then @@ -49,7 +51,40 @@ end minetest.register_lbm({ name = "signs:conpatibility_1", nodenames = {"signs:wooden_right", "signs:wooden_left", "signs:poster"}, - action = compatibility_check, + action = compatibility_check_1, }) +-- Text entity name change because of signs_lib using signs prefix +------------------------------------------------------------------ + +-- If no other mod registered signs:text, register it. +-- We need to have this entity registered to be able to remove it. +if minetest.registered_entities["signs:text"] == nil then + minetest.register_entity("signs:text", { + collisionbox = { 0, 0, 0, 0, 0, 0 }, + visual = "upright_sprite", + textures = {}, + }) +end + +local function compatibility_check_2(pos, node) + -- Remove old entity + for _, objref in ipairs(minetest.get_objects_inside_radius(pos, 0.5)) do + local entity = objref:get_luaentity() + if entity and entity.name == "signs:text" then + objref:remove() + end + end + -- Create new entity + display_lib.update_entities(pos) +end + +minetest.register_lbm({ name = "signs:conpatibility_2", + nodenames = {"signs:wooden_right_sign", "signs:wooden_left_sign", "signs:paper_poster"}, + action = compatibility_check_2, +}) + + + + -- cgit v1.2.3