Add /sleep command.
This commit is contained in:
parent
193ad7e7ac
commit
01cef3d1bd
2 changed files with 30 additions and 2 deletions
28
chat.lua
28
chat.lua
|
@ -235,3 +235,31 @@ minetest.register_chatcommand("flatten", {
|
|||
vm:update_map()
|
||||
end,
|
||||
})
|
||||
|
||||
|
||||
minetest.register_chatcommand("sleep", {
|
||||
params = "",
|
||||
description = "Sleep on the ground",
|
||||
privs = {},
|
||||
func = function(player_name, param)
|
||||
local player = minetest.get_player_by_name(player_name)
|
||||
if not (player and beds) then
|
||||
return
|
||||
end
|
||||
|
||||
local pos = player:getpos()
|
||||
if not pos then
|
||||
return
|
||||
end
|
||||
pos = vector.round(pos)
|
||||
|
||||
beds.on_rightclick(pos, player)
|
||||
|
||||
local hp = player:get_hp()
|
||||
if hp and type(hp) == 'number' then
|
||||
player:set_hp(hp - 1)
|
||||
end
|
||||
|
||||
minetest.chat_send_player(player_name, 'You\'d sleep better in a bed.')
|
||||
end,
|
||||
})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue