---
init.lua | 26 ++++++++++++++++++++++++++
1 file changed, 26 insertions(+)
diff --git a/init.lua b/init.lua
index a24e8ce..27ac710 100644
--- a/init.lua
+++ b/init.lua
@@ -236,6 +236,15 @@ minetest.register_node("teleport_potion:pad", {
local meta = minetest.get_meta(pos)
+ local old_target_coords = {
+ x = meta:get_int("x"),
+ y = meta:get_int("y"),
+ z = meta:get_int("z")
+ }
+
+ local teleport_to_string = minetest.pos_to_string(coords)
+ local teleport_from_string = minetest.pos_to_string(old_target_coords)
+
meta:set_int("x", coords.x)
meta:set_int("y", coords.y)
meta:set_int("z", coords.z)
@@ -249,6 +258,9 @@ minetest.register_node("teleport_potion:pad", {
.. coords.x .. "," .. coords.y .. "," .. coords.z .. ")")
end
+ -- logging the teleportation
+ minetest.log("action", name .. " changed teleport pad from " .. teleport_from_string .. " to " .. teleport_to_string)
+
minetest.sound_play("portal_open", {
pos = pos,
gain = 1.0,
@@ -288,6 +300,9 @@ minetest.register_abm({
end
-- get coords from pad/portal
+
+ local original_object_pos = minetest.pos_to_string(pos)
+
local meta = minetest.get_meta(pos)
local target_coords = {
x = meta:get_int("x"),
@@ -298,6 +313,8 @@ minetest.register_abm({
for k, player in pairs(objs) do
if player then
+ local player_name = player:get_player_name()
+ local teleport_to_string = minetest.pos_to_string(target_coords)
-- play sound on portal end
minetest.sound_play("portal_close", {
@@ -309,6 +326,9 @@ minetest.register_abm({
-- move player/object
player:setpos(target_coords)
+ -- logging the teleportation
+ minetest.log("action", player_name .. " teleported from " .. original_object_pos .. " to " .. teleport_to_string )
+
-- paricle effects on arrival
tp_effect(target_coords)
@@ -354,12 +374,18 @@ potion_entity.on_step = function(self, dtime)
or vel.z == 0 then
if self.player ~= "" then
+ local player_name = self.player:get_player_name()
+ local teleport_to_string = minetest.pos_to_string(self.lastpos)
+ local teleport_from_string = minetest.pos_to_string(pos)
-- round up coords to fix glitching through doors
self.lastpos = vector.round(self.lastpos)
self.player:setpos(self.lastpos)
+ -- logging the teleportation
+ minetest.log("action", player_name .. " teleported to " .. teleport_to_string .. " from " .. original_object_pos)
+
minetest.sound_play("portal_close", {
pos = self.lastpos,
gain = 1.0,
--
2.17.1