Forced player to stay still to teleport

master
Giov4 2022-06-28 16:08:56 +00:00
parent 6bd14cf1f3
commit ff7ee0dbb8
3 changed files with 16 additions and 2 deletions

View File

@ -9,6 +9,7 @@ Magic Compass=Bussola Magica
# player_manager.lua
[!] This location is not available for you at the moment!=[!] Non ti è consentito l'accesso a questo luogo ora!
[!] You can't reteleport to this location so quickly! (seconds remaining: @1)=[!] Non puoi ritelerasportarti in questo luogo così velocemente! (secondi rimanenti: @1)
[!] Can't teleport whilst moving!=[!] Non puoi telerasportarti mentre ti muovi!
# SETTINGS.lua
You can change title and bg in SETTINGS.lua!=Puoi cambiare titolo e sfondo in SETTINGS.lua!

View File

@ -9,6 +9,7 @@ Magic Compass=
# player_manager.lua
[!] This location is not available for you at the moment!=
[!] You can't reteleport to this location so quickly! (seconds remaining: @1)=
[!] Can't teleport whilst moving!=
# SETTINGS.lua
You can change title and bg in SETTINGS.lua!=

View File

@ -124,7 +124,8 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
minetest.sound_play("magiccompass_teleport_deny", {
to_player = p_name
})
return end
return
end
-- se è in cooldown, annullo
if item.cooldown and on_cooldown[p_name] and on_cooldown[p_name][ID] then
@ -132,7 +133,18 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
minetest.sound_play("magiccompass_teleport_deny", {
to_player = p_name
})
return end
return
end
minetest.log(vector.length(player:get_velocity()))
-- se non è fermo, annullo
if vector.length(player:get_velocity()) > 0.2 then
minetest.chat_send_player(p_name, minetest.colorize("#e6482e", S("[!] Can't teleport whilst moving!")))
minetest.sound_play("magiccompass_teleport_deny", {
to_player = p_name
})
return
end
-- se non passa gli eventuali richiami, annullo
for _, callback in ipairs(magic_compass.registered_on_use) do