Force teleport to update formspec by punching

master
Wuzzy 2020-09-08 21:23:45 +02:00
parent c0c4d5f627
commit 0519791f0a
2 changed files with 14 additions and 2 deletions

View File

@ -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

View File

@ -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"},
}
})