mirror of
https://codeberg.org/tenplus1/teleport_potion.git
synced 2025-03-15 06:01:24 +00:00
only teleport players, use 0.4.16+ code changes
This commit is contained in:
parent
d22ab00772
commit
869dea628e
2 changed files with 21 additions and 26 deletions
|
@ -7,6 +7,7 @@ https://forum.minetest.net/viewtopic.php?f=9&t=9234
|
||||||
|
|
||||||
Change log:
|
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
|
- 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.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
|
- 0.8 - Teleport pads now have arrows showing direction player will face after use
|
||||||
|
|
46
init.lua
46
init.lua
|
@ -143,19 +143,19 @@ local function throw_potion(itemstack, player)
|
||||||
local dir = player:get_look_dir()
|
local dir = player:get_look_dir()
|
||||||
local velocity = 20
|
local velocity = 20
|
||||||
|
|
||||||
obj:setvelocity({
|
obj:set_velocity({
|
||||||
x = dir.x * velocity,
|
x = dir.x * velocity,
|
||||||
y = dir.y * velocity,
|
y = dir.y * velocity,
|
||||||
z = dir.z * velocity
|
z = dir.z * velocity
|
||||||
})
|
})
|
||||||
|
|
||||||
obj:setacceleration({
|
obj:set_acceleration({
|
||||||
x = dir.x * -3,
|
x = dir.x * -3,
|
||||||
y = -9.5,
|
y = -9.5,
|
||||||
z = dir.z * -3
|
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
|
obj:get_luaentity().player = player
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -181,7 +181,7 @@ potion_entity.on_step = function(self, dtime)
|
||||||
|
|
||||||
if self.lastpos.x ~= nil then
|
if self.lastpos.x ~= nil then
|
||||||
|
|
||||||
local vel = self.object:getvelocity()
|
local vel = self.object:get_velocity()
|
||||||
|
|
||||||
-- only when potion hits something physical
|
-- only when potion hits something physical
|
||||||
if vel.x == 0
|
if vel.x == 0
|
||||||
|
@ -193,7 +193,7 @@ potion_entity.on_step = function(self, dtime)
|
||||||
-- round up coords to fix glitching through doors
|
-- round up coords to fix glitching through doors
|
||||||
self.lastpos = vector.round(self.lastpos)
|
self.lastpos = vector.round(self.lastpos)
|
||||||
|
|
||||||
self.player:setpos(self.lastpos)
|
self.player:set_pos(self.lastpos)
|
||||||
|
|
||||||
minetest.sound_play("portal_close", {
|
minetest.sound_play("portal_close", {
|
||||||
pos = self.lastpos,
|
pos = self.lastpos,
|
||||||
|
@ -445,10 +445,7 @@ minetest.register_abm({
|
||||||
|
|
||||||
for n = 1, #objs do
|
for n = 1, #objs do
|
||||||
|
|
||||||
local item = objs[n] and objs[n]:get_luaentity()
|
if objs[n]:is_player() then
|
||||||
and objs[n]:get_luaentity().name or ""
|
|
||||||
|
|
||||||
if item ~= "itemframes:item" and item ~= "signs:text" then
|
|
||||||
|
|
||||||
-- play sound on portal end
|
-- play sound on portal end
|
||||||
minetest.sound_play("portal_close", {
|
minetest.sound_play("portal_close", {
|
||||||
|
@ -457,8 +454,8 @@ minetest.register_abm({
|
||||||
max_hear_distance = 5
|
max_hear_distance = 5
|
||||||
})
|
})
|
||||||
|
|
||||||
-- move player/object
|
-- move player
|
||||||
objs[n]:setpos(target_coords)
|
objs[n]:set_pos(target_coords)
|
||||||
|
|
||||||
-- paricle effects on arrival
|
-- paricle effects on arrival
|
||||||
tp_effect(target_coords)
|
tp_effect(target_coords)
|
||||||
|
@ -471,23 +468,20 @@ minetest.register_abm({
|
||||||
})
|
})
|
||||||
|
|
||||||
-- rotate player to look in pad placement direction
|
-- 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
|
if rot == 0 or rot == 20 then
|
||||||
local yaw = 0
|
yaw = 0 -- north
|
||||||
|
elseif rot == 2 or rot == 22 then
|
||||||
if rot == 0 or rot == 20 then
|
yaw = 3.14 -- south
|
||||||
yaw = 0 -- north
|
elseif rot == 1 or rot == 23 then
|
||||||
elseif rot == 2 or rot == 22 then
|
yaw = 4.71 -- west
|
||||||
yaw = 3.14 -- south
|
elseif rot == 3 or rot == 21 then
|
||||||
elseif rot == 1 or rot == 23 then
|
yaw = 1.57 -- east
|
||||||
yaw = 4.71 -- west
|
|
||||||
elseif rot == 3 or rot == 21 then
|
|
||||||
yaw = 1.57 -- east
|
|
||||||
end
|
|
||||||
|
|
||||||
objs[n]:set_look_yaw(yaw)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
objs[n]:set_look_yaw(yaw)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Reference in a new issue