From 58408a6f073b388fe93262a4b2a6fad5f8301c71 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Rollo Date: Sun, 10 Dec 2017 11:03:23 +0100 Subject: [PATCH] Added LBM to automatically update entities from signs:text to signs:display_text --- signs/compatibility.lua | 39 ++++++++++++++++++++++++++++++++++-- signs_road/compatibility.lua | 27 +++++++++++++++++++++++++ 2 files changed, 64 insertions(+), 2 deletions(-) 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, }) + + + diff --git a/signs_road/compatibility.lua b/signs_road/compatibility.lua index 4ef25ba..fa5f94b 100644 --- a/signs_road/compatibility.lua +++ b/signs_road/compatibility.lua @@ -19,6 +19,8 @@ --]] -- Wallmounted to facedir conversion +------------------------------------ + local wallmounted_to_facedir = { [0]=1, -- Should not happend with signs [1]=1, -- Should not happend with signs @@ -55,4 +57,29 @@ minetest.register_lbm({ name = "signs_road:conpatibility_1", action = compatibility_check, }) +-- Text entity name change because of signs_lib using signs prefix +------------------------------------------------------------------ + +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_road:conpatibility_2", + nodenames = { + "signs_road:blue_street_sign", "signs_road:red_street_sign", "signs_road:white_street_sign", + "signs_road:green_street_sign", "signs_road:yellow_street_sign", "signs_road:black_right_sign", + "signs_road:black_left_sign", "signs_road:green_right_sign", "signs_road:green_left_sign", + "signs_road:yellow_right_sign", "signs_road:yellow_left_sign", "signs_road:white_right_sign", + "signs_road:white_left_sign"}, + action = compatibility_check_2, +}) +