Add /sleep command.

This commit is contained in:
Duane 2016-07-17 03:55:51 -05:00
parent 193ad7e7ac
commit 01cef3d1bd
2 changed files with 30 additions and 2 deletions

View file

@ -235,3 +235,31 @@ minetest.register_chatcommand("flatten", {
vm:update_map() vm:update_map()
end, 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,
})

View file

@ -617,8 +617,8 @@ if minetest.registered_entities["mobs_monster:spider"] then
m.collisionbox = {-0.32, -0.0, -0.25, 0.25, 0.25, 0.25} m.collisionbox = {-0.32, -0.0, -0.25, 0.25, 0.25, 0.25}
m.visual_size = {x = 1.5, y = 1.5} m.visual_size = {x = 1.5, y = 1.5}
m.drops = { m.drops = {
{name = "mobs:meat_raw", chance = 2, min = 1, max = 1}, {name = "mobs:meat_raw", chance = 2, min = 1, max = 4},
{name = "farming:cotton", chance = 2, min = 1, max = 2}, {name = "farming:cotton", chance = 2, min = 1, max = 4},
} }
m.do_custom = function(self) m.do_custom = function(self)
if not (self and fun_caves.custom_ready(self)) then if not (self and fun_caves.custom_ready(self)) then