forked from minetest-mods/unified_inventory
require "home" privilege to use home/sethome buttons
This commit is contained in:
parent
8338b406d3
commit
2355dc6fc2
27
register.lua
27
register.lua
|
@ -40,13 +40,18 @@ if not unified_inventory.lite_mode then
|
||||||
tooltip = S("Set home position"),
|
tooltip = S("Set home position"),
|
||||||
action = function(player)
|
action = function(player)
|
||||||
local player_name = player:get_player_name()
|
local player_name = player:get_player_name()
|
||||||
unified_inventory.set_home(player, player:getpos())
|
if minetest.check_player_privs(player_name, {home=true}) then
|
||||||
local home = unified_inventory.home_pos[player_name]
|
unified_inventory.set_home(player, player:getpos())
|
||||||
if home ~= nil then
|
local home = unified_inventory.home_pos[player_name]
|
||||||
minetest.sound_play("dingdong",
|
if home ~= nil then
|
||||||
{to_player=player_name, gain = 1.0})
|
minetest.sound_play("dingdong",
|
||||||
|
{to_player=player_name, gain = 1.0})
|
||||||
|
minetest.chat_send_player(player_name,
|
||||||
|
S("Home position set to: %s"):format(minetest.pos_to_string(home)))
|
||||||
|
end
|
||||||
|
else
|
||||||
minetest.chat_send_player(player_name,
|
minetest.chat_send_player(player_name,
|
||||||
S("Home position set to: %s"):format(minetest.pos_to_string(home)))
|
S("You don't have the \"home\" privilege!"))
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
@ -56,9 +61,15 @@ if not unified_inventory.lite_mode then
|
||||||
image = "ui_gohome_icon.png",
|
image = "ui_gohome_icon.png",
|
||||||
tooltip = S("Go home"),
|
tooltip = S("Go home"),
|
||||||
action = function(player)
|
action = function(player)
|
||||||
minetest.sound_play("teleport",
|
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})
|
{to_player=player:get_player_name(), gain = 1.0})
|
||||||
unified_inventory.go_home(player)
|
unified_inventory.go_home(player)
|
||||||
|
else
|
||||||
|
minetest.chat_send_player(player_name,
|
||||||
|
S("You don't have the \"home\" privilege!"))
|
||||||
|
end
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user