From 869dea628e91bd6ff5722e8c368f65f3369c58ba Mon Sep 17 00:00:00 2001 From: TenPlus1 Date: Mon, 22 Oct 2018 14:47:57 +0100 Subject: [PATCH] only teleport players, use 0.4.16+ code changes --- README.md | 1 + init.lua | 46 ++++++++++++++++++++-------------------------- 2 files changed, 21 insertions(+), 26 deletions(-) diff --git a/README.md b/README.md index 9354ba4..acf46cf 100644 --- a/README.md +++ b/README.md @@ -7,6 +7,7 @@ https://forum.minetest.net/viewtopic.php?f=9&t=9234 Change log: +- 1.1 - Using 0.4.16+ code changes, can only teleport players now - 1.0 - Added changes by maybe_dragon to bookmark teleport destination before using pads and potions - 0.9 - Update to newer functions, requires Minetest 0.4.16 to work. - 0.8 - Teleport pads now have arrows showing direction player will face after use diff --git a/init.lua b/init.lua index 606e7ae..0ca4cf6 100644 --- a/init.lua +++ b/init.lua @@ -143,19 +143,19 @@ local function throw_potion(itemstack, player) local dir = player:get_look_dir() local velocity = 20 - obj:setvelocity({ + obj:set_velocity({ x = dir.x * velocity, y = dir.y * velocity, z = dir.z * velocity }) - obj:setacceleration({ + obj:set_acceleration({ x = dir.x * -3, y = -9.5, z = dir.z * -3 }) - obj:setyaw(player:get_look_yaw() + math.pi) + obj:set_yaw(player:get_look_yaw() + math.pi) obj:get_luaentity().player = player end @@ -181,7 +181,7 @@ potion_entity.on_step = function(self, dtime) if self.lastpos.x ~= nil then - local vel = self.object:getvelocity() + local vel = self.object:get_velocity() -- only when potion hits something physical if vel.x == 0 @@ -193,7 +193,7 @@ potion_entity.on_step = function(self, dtime) -- round up coords to fix glitching through doors self.lastpos = vector.round(self.lastpos) - self.player:setpos(self.lastpos) + self.player:set_pos(self.lastpos) minetest.sound_play("portal_close", { pos = self.lastpos, @@ -445,10 +445,7 @@ minetest.register_abm({ for n = 1, #objs do - local item = objs[n] and objs[n]:get_luaentity() - and objs[n]:get_luaentity().name or "" - - if item ~= "itemframes:item" and item ~= "signs:text" then + if objs[n]:is_player() then -- play sound on portal end minetest.sound_play("portal_close", { @@ -457,8 +454,8 @@ minetest.register_abm({ max_hear_distance = 5 }) - -- move player/object - objs[n]:setpos(target_coords) + -- move player + objs[n]:set_pos(target_coords) -- paricle effects on arrival tp_effect(target_coords) @@ -471,23 +468,20 @@ minetest.register_abm({ }) -- rotate player to look in pad placement direction - if objs[n]:is_player() then + local rot = node.param2 + local yaw = 0 - local rot = node.param2 - local yaw = 0 - - if rot == 0 or rot == 20 then - yaw = 0 -- north - elseif rot == 2 or rot == 22 then - yaw = 3.14 -- south - elseif rot == 1 or rot == 23 then - yaw = 4.71 -- west - elseif rot == 3 or rot == 21 then - yaw = 1.57 -- east - end - - objs[n]:set_look_yaw(yaw) + if rot == 0 or rot == 20 then + yaw = 0 -- north + elseif rot == 2 or rot == 22 then + yaw = 3.14 -- south + elseif rot == 1 or rot == 23 then + yaw = 4.71 -- west + elseif rot == 3 or rot == 21 then + yaw = 1.57 -- east end + + objs[n]:set_look_yaw(yaw) end end end