From 0519791f0a4a7cba91c66de031dd7bed4e8289b2 Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Tue, 8 Sep 2020 21:23:45 +0200 Subject: [PATCH] Force teleport to update formspec by punching --- README.txt | 10 +++++++++- init.lua | 6 +++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/README.txt b/README.txt index 9c6e8ac..37ef10a 100644 --- a/README.txt +++ b/README.txt @@ -1,7 +1,7 @@ teleports ========= -Mod "teleports" for Minetest 0.4.17 or later. +Mod "teleports" for Minetest 0.4.17 or later. Updated version of lag01's Teleports mod! Allows players to create teleports with crafting (8 diamonds + 1 obsidian). @@ -17,6 +17,14 @@ the destination exactly, but one block 'besides' it. Beware: If you dig a teleport, you only get 1 diamond back, so think before placing! +For server operators +-------------------- + +This mod is compatible with lag01's original teleports mod. The formspecs have changed tho +because the original mod's formspec were buggy. + +To force a teleport to update its formspec, just punch it! + Credits: ======== This mod code is licensed under the GNU LGPLv2 diff --git a/init.lua b/init.lua index 71a299d..70c93a5 100644 --- a/init.lua +++ b/init.lua @@ -258,6 +258,11 @@ minetest.register_node("teleports:teleport", { teleports:save() end end, + on_punch = function(pos, node, puncher, pointed_thing) + -- Force formspec update on punch + teleports.set_formspec(pos) + minetest.log("info", "[teleports] Teleport formspec force-updated: "..minetest.pos_to_string(pos)) + end, on_destruct = function(pos) -- Update list of teleports on destruction local near_teleports = teleports:find_nearby(pos, TELEPORT_SHOW_MAX) @@ -326,4 +331,3 @@ minetest.register_craft({ {"default:diamond","default:diamond","default:diamond"}, } }) -