Fix teleport sounds when teleport fails (#155)

This commit is contained in:
Maksim 2020-07-10 21:58:45 +02:00 committed by GitHub
parent 04b2edceb4
commit f25426911d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 3 deletions

View File

@ -188,7 +188,9 @@ function unified_inventory.go_home(player)
local pos = unified_inventory.home_pos[player:get_player_name()]
if pos then
player:set_pos(pos)
return true
end
return false
end
-- register_craft

View File

@ -76,9 +76,9 @@ unified_inventory.register_button("home_gui_go", {
action = function(player)
local player_name = player:get_player_name()
if minetest.check_player_privs(player_name, {home=true}) then
minetest.sound_play("teleport",
{to_player=player:get_player_name(), gain = 1.0})
unified_inventory.go_home(player)
if unified_inventory.go_home(player) then
minetest.sound_play("teleport", {to_player = player_name})
end
else
minetest.chat_send_player(player_name,
S("You don't have the \"home\" privilege!"))