2017-05-15 19:44:27 +02:00
|
|
|
|
2015-09-01 17:15:24 +02:00
|
|
|
--
|
|
|
|
-- Bed mod
|
|
|
|
-- By PilzAdam, thefamilygrog66
|
|
|
|
-- Tweaked by Kaadmy, for Pixture
|
|
|
|
--
|
|
|
|
|
2019-08-28 17:31:41 +02:00
|
|
|
local S = minetest.get_translator("bed")
|
|
|
|
|
2017-05-15 19:44:27 +02:00
|
|
|
bed = {}
|
|
|
|
|
|
|
|
-- Per-user data table
|
|
|
|
|
|
|
|
bed.userdata = {}
|
2020-01-31 02:05:05 +01:00
|
|
|
bed.userdata.saved = {}
|
|
|
|
bed.userdata.temp = {}
|
2017-05-15 19:44:27 +02:00
|
|
|
|
2017-05-16 20:31:46 +02:00
|
|
|
-- Savefile
|
|
|
|
|
2017-05-15 19:44:27 +02:00
|
|
|
local bed_file = minetest.get_worldpath() .. "/bed.dat"
|
|
|
|
local saving = false
|
|
|
|
|
2017-05-16 20:31:46 +02:00
|
|
|
-- Timer
|
|
|
|
|
|
|
|
local timer_interval = 1
|
2017-05-15 19:44:27 +02:00
|
|
|
local timer = 0
|
|
|
|
|
|
|
|
local delay_daytime = false
|
|
|
|
|
|
|
|
local function is_bed_node(pos)
|
|
|
|
if pos == nil then
|
|
|
|
return false
|
|
|
|
end
|
|
|
|
|
|
|
|
local node = minetest.get_node(pos)
|
|
|
|
|
|
|
|
if node.name == "bed:bed_foot" then
|
|
|
|
return true
|
|
|
|
end
|
|
|
|
|
|
|
|
return false
|
|
|
|
end
|
|
|
|
|
|
|
|
local function put_player_in_bed(player)
|
|
|
|
if player == nil then
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
|
|
|
local name = player:get_player_name()
|
|
|
|
|
2020-01-31 02:05:05 +01:00
|
|
|
if bed.userdata.temp[name].slept
|
|
|
|
and not is_bed_node(bed.userdata.temp[name].node_pos) then
|
2017-05-15 19:44:27 +02:00
|
|
|
return
|
|
|
|
end
|
|
|
|
|
2020-01-31 02:05:05 +01:00
|
|
|
player:set_look_horizontal(bed.userdata.saved[name].spawn_yaw)
|
|
|
|
player:set_pos(bed.userdata.saved[name].spawn_pos)
|
2017-05-15 19:44:27 +02:00
|
|
|
|
|
|
|
player_effects.apply_effect(player, "inbed")
|
|
|
|
|
|
|
|
player:set_eye_offset(vector.new(0, -13, 0), vector.new(0, -13, 0))
|
|
|
|
player:set_local_animation(
|
|
|
|
{x=162, y=166},
|
|
|
|
{x=162, y=166},
|
|
|
|
{x=162, y=166},
|
|
|
|
{x=162, y=168},
|
2017-05-15 23:41:46 +02:00
|
|
|
default.player_animation_speed)
|
2017-05-15 19:44:27 +02:00
|
|
|
|
2017-05-16 20:31:46 +02:00
|
|
|
default.player_set_animation(player, "lay", default.player_animation_speed)
|
2017-05-15 19:44:27 +02:00
|
|
|
|
|
|
|
default.player_attached[name] = true
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
local function take_player_from_bed(player)
|
|
|
|
if player == nil then
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
|
|
|
local name = player:get_player_name()
|
|
|
|
|
2020-01-31 02:05:05 +01:00
|
|
|
if bed.userdata.saved[name].spawn_pos then
|
|
|
|
player:set_pos(bed.userdata.saved[name].spawn_pos)
|
|
|
|
end
|
2017-05-15 19:44:27 +02:00
|
|
|
|
|
|
|
player_effects.remove_effect(player, "inbed")
|
|
|
|
|
|
|
|
player:set_eye_offset(vector.new(0, 0, 0), vector.new(0, 0, 0))
|
|
|
|
player:set_local_animation(
|
|
|
|
{x=0, y=79},
|
|
|
|
{x=168, y=187},
|
|
|
|
{x=189, y=198},
|
|
|
|
{x=200, y=219},
|
2017-05-15 23:41:46 +02:00
|
|
|
default.player_animation_speed)
|
2017-05-15 19:44:27 +02:00
|
|
|
|
2017-05-15 23:41:46 +02:00
|
|
|
default.player_set_animation(player, "stand", default.player_animation_speed)
|
2017-05-15 19:44:27 +02:00
|
|
|
|
|
|
|
default.player_attached[name] = false
|
|
|
|
end
|
|
|
|
|
|
|
|
local function save_bed()
|
|
|
|
local f = io.open(bed_file, "w")
|
|
|
|
|
2020-01-31 02:05:05 +01:00
|
|
|
f:write(minetest.serialize(bed.userdata.saved))
|
2017-05-15 19:44:27 +02:00
|
|
|
|
|
|
|
io.close(f)
|
|
|
|
|
|
|
|
saving = false
|
|
|
|
end
|
|
|
|
|
|
|
|
local function delayed_save()
|
|
|
|
if not saving then
|
|
|
|
saving = true
|
|
|
|
|
|
|
|
minetest.after(40, save_bed)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
local function load_bed()
|
|
|
|
local f = io.open(bed_file, "r")
|
|
|
|
|
|
|
|
if f then
|
2020-01-31 02:05:05 +01:00
|
|
|
bed.userdata.saved = minetest.deserialize(f:read("*all"))
|
2017-05-15 19:44:27 +02:00
|
|
|
|
|
|
|
io.close(f)
|
|
|
|
else
|
|
|
|
save_bed()
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2017-05-16 20:31:46 +02:00
|
|
|
-- Server start
|
|
|
|
|
2017-05-15 19:44:27 +02:00
|
|
|
local function on_load()
|
|
|
|
load_bed()
|
|
|
|
end
|
|
|
|
|
2017-05-16 20:31:46 +02:00
|
|
|
-- Server shutdown
|
|
|
|
|
2017-05-15 19:44:27 +02:00
|
|
|
local function on_shutdown()
|
|
|
|
save_bed()
|
|
|
|
end
|
|
|
|
|
2017-05-16 20:31:46 +02:00
|
|
|
-- Joining player
|
|
|
|
|
2017-05-15 19:44:27 +02:00
|
|
|
local function on_joinplayer(player)
|
|
|
|
local name = player:get_player_name()
|
|
|
|
|
2020-01-31 02:05:05 +01:00
|
|
|
if not bed.userdata.saved[name] then
|
|
|
|
bed.userdata.saved[name] = {
|
2017-05-15 19:44:27 +02:00
|
|
|
spawn_yaw = 0,
|
|
|
|
spawn_pos = nil,
|
2020-01-31 02:05:05 +01:00
|
|
|
}
|
|
|
|
end
|
|
|
|
bed.userdata.temp[name] = {
|
|
|
|
in_bed = false,
|
2017-05-15 19:44:27 +02:00
|
|
|
slept = false,
|
|
|
|
node_pos = nil,
|
|
|
|
}
|
2020-01-31 02:05:05 +01:00
|
|
|
delayed_save()
|
2017-05-15 19:44:27 +02:00
|
|
|
end
|
|
|
|
|
2017-05-16 20:31:46 +02:00
|
|
|
-- Respawning player
|
|
|
|
|
2017-05-15 19:44:27 +02:00
|
|
|
local function on_respawnplayer(player)
|
|
|
|
local name = player:get_player_name()
|
|
|
|
|
2020-01-31 02:05:05 +01:00
|
|
|
if bed.userdata.temp[name] then
|
|
|
|
if not bed.userdata.temp[name].slept then
|
2017-05-15 19:44:27 +02:00
|
|
|
return
|
|
|
|
end
|
|
|
|
|
2020-01-31 02:05:05 +01:00
|
|
|
bed.userdata.temp[name].in_bed = false
|
2017-05-15 19:44:27 +02:00
|
|
|
|
|
|
|
take_player_from_bed(player)
|
|
|
|
|
|
|
|
return true
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2017-05-16 20:31:46 +02:00
|
|
|
-- Update function
|
|
|
|
|
2017-05-15 19:44:27 +02:00
|
|
|
local function on_globalstep(dtime)
|
|
|
|
timer = timer + dtime
|
|
|
|
|
2017-05-16 20:31:46 +02:00
|
|
|
if timer < timer_interval then
|
2017-05-15 19:44:27 +02:00
|
|
|
return
|
|
|
|
end
|
|
|
|
|
|
|
|
timer = 0
|
|
|
|
|
|
|
|
local sleeping_players = 0
|
|
|
|
|
2020-01-31 02:05:05 +01:00
|
|
|
local in_bed = {}
|
|
|
|
for name, data in pairs(bed.userdata.temp) do
|
2017-05-15 19:44:27 +02:00
|
|
|
if data.in_bed then
|
2017-05-16 20:31:46 +02:00
|
|
|
local player = minetest.get_player_by_name(name)
|
2020-01-31 02:05:05 +01:00
|
|
|
if player then
|
|
|
|
table.insert(in_bed, name)
|
|
|
|
sleeping_players = sleeping_players + 1
|
2017-05-16 20:31:46 +02:00
|
|
|
end
|
2017-05-15 19:44:27 +02:00
|
|
|
end
|
|
|
|
end
|
2020-01-31 02:05:05 +01:00
|
|
|
for p=1, #in_bed do
|
|
|
|
local data = bed.userdata.saved[in_bed[p]]
|
|
|
|
if data then
|
|
|
|
local player = minetest.get_player_by_name(in_bed[p])
|
|
|
|
if vector.distance(player:get_pos(), data.spawn_pos) > 2 then
|
|
|
|
player:move_to(data.spawn_pos)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2017-05-15 19:44:27 +02:00
|
|
|
|
2017-05-16 20:31:46 +02:00
|
|
|
local players = minetest.get_connected_players()
|
|
|
|
local player_count = #players
|
2017-05-15 19:44:27 +02:00
|
|
|
|
2017-05-16 20:31:46 +02:00
|
|
|
if player_count > 0 and (player_count / 2.0) < sleeping_players then
|
2017-05-15 19:44:27 +02:00
|
|
|
if minetest.get_timeofday() < 0.2 or minetest.get_timeofday() > 0.8 then
|
|
|
|
if not delay_daytime then
|
|
|
|
delay_daytime = true
|
|
|
|
|
|
|
|
minetest.after(
|
|
|
|
2,
|
|
|
|
function()
|
|
|
|
minetest.set_timeofday(0.23)
|
|
|
|
delay_daytime = false
|
|
|
|
|
2019-08-29 17:39:51 +02:00
|
|
|
local players = minetest.get_connected_players()
|
2017-05-16 20:31:46 +02:00
|
|
|
for _, player in ipairs(players) do
|
2020-01-31 02:05:05 +01:00
|
|
|
if bed.userdata.temp[player:get_player_name()].in_bed then
|
|
|
|
bed.userdata.temp[player:get_player_name()].slept = true
|
2017-05-15 19:44:27 +02:00
|
|
|
end
|
|
|
|
end
|
2019-10-24 14:09:55 +02:00
|
|
|
|
|
|
|
local msg
|
|
|
|
if #players == 1 then
|
|
|
|
msg = S("You have slept, rise and shine!")
|
|
|
|
else
|
|
|
|
msg = S("Players have slept, rise and shine!")
|
|
|
|
end
|
|
|
|
minetest.chat_send_all(minetest.colorize("#0ff", "*** " .. msg))
|
2017-05-15 19:44:27 +02:00
|
|
|
end)
|
|
|
|
|
|
|
|
delayed_save()
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2019-08-29 17:39:51 +02:00
|
|
|
minetest.register_on_mods_loaded(on_load)
|
2017-05-15 19:44:27 +02:00
|
|
|
|
|
|
|
minetest.register_on_shutdown(on_shutdown)
|
|
|
|
|
|
|
|
minetest.register_on_joinplayer(on_joinplayer)
|
|
|
|
|
|
|
|
minetest.register_on_respawnplayer(on_respawnplayer)
|
|
|
|
|
|
|
|
minetest.register_globalstep(on_globalstep)
|
2015-09-01 17:15:24 +02:00
|
|
|
|
2017-05-16 20:31:46 +02:00
|
|
|
-- Nodes
|
|
|
|
|
2017-05-12 04:29:55 +02:00
|
|
|
minetest.register_node(
|
2015-09-01 17:15:24 +02:00
|
|
|
"bed:bed_foot",
|
|
|
|
{
|
2019-08-28 17:31:41 +02:00
|
|
|
description = S("Bed"),
|
2019-12-05 10:30:46 +01:00
|
|
|
_tt_help = S("Use it to sleep and pass the night"),
|
2015-09-01 17:15:24 +02:00
|
|
|
drawtype = "nodebox",
|
|
|
|
paramtype = "light",
|
|
|
|
paramtype2 = "facedir",
|
2015-10-10 08:23:27 +02:00
|
|
|
sunlight_propagates = true,
|
|
|
|
wield_image = "bed_bed_inventory.png",
|
|
|
|
inventory_image = "bed_bed_inventory.png",
|
|
|
|
tiles = {"bed_foot.png", "default_wood.png", "bed_side.png"},
|
2021-02-04 22:08:51 +01:00
|
|
|
use_texture_alpha = "clip",
|
2019-08-31 14:06:32 +02:00
|
|
|
groups = {snappy = 1, choppy = 2, oddly_breakable_by_hand = 2, flammable = 3, bed = 1},
|
2019-08-29 14:52:32 +02:00
|
|
|
is_ground_content = false,
|
2015-09-01 17:15:24 +02:00
|
|
|
sounds = default.node_sound_wood_defaults(),
|
|
|
|
node_box = {
|
|
|
|
type = "fixed",
|
2015-10-10 08:23:27 +02:00
|
|
|
fixed = {-0.5, -0.5, -0.5, 0.5, 2/16, 0.5}
|
2015-09-01 17:15:24 +02:00
|
|
|
},
|
|
|
|
selection_box = {
|
|
|
|
type = "fixed",
|
2015-10-10 08:23:27 +02:00
|
|
|
fixed = {-0.5, -0.5, -0.5, 0.5, 2/16, 1.5}
|
2015-09-01 17:15:24 +02:00
|
|
|
},
|
2015-10-10 08:23:27 +02:00
|
|
|
|
2019-08-29 18:10:11 +02:00
|
|
|
on_place = function(itemstack, placer, pointed_thing)
|
|
|
|
local under = pointed_thing.under
|
|
|
|
|
|
|
|
-- Use pointed node's on_rightclick function first, if present
|
|
|
|
local node = minetest.get_node(under)
|
|
|
|
if placer and not placer:get_player_control().sneak then
|
|
|
|
if minetest.registered_nodes[node.name] and minetest.registered_nodes[node.name].on_rightclick then
|
|
|
|
return minetest.registered_nodes[node.name].on_rightclick(pointed_thing.under, node, placer, itemstack) or itemstack
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
local pos
|
|
|
|
local undername = minetest.get_node(under).name
|
|
|
|
if minetest.registered_items[undername] and minetest.registered_items[undername].buildable_to then
|
|
|
|
pos = under
|
|
|
|
else
|
|
|
|
pos = pointed_thing.above
|
|
|
|
end
|
|
|
|
|
|
|
|
if minetest.is_protected(pos, placer:get_player_name()) and
|
|
|
|
not minetest.check_player_privs(placer, "protection_bypass") then
|
|
|
|
minetest.record_protection_violation(pos, placer:get_player_name())
|
|
|
|
return itemstack
|
|
|
|
end
|
|
|
|
|
|
|
|
local node_def = minetest.registered_nodes[minetest.get_node(pos).name]
|
|
|
|
if not node_def or not node_def.buildable_to then
|
|
|
|
return itemstack
|
|
|
|
end
|
|
|
|
|
|
|
|
local dir = minetest.dir_to_facedir(placer:get_look_dir())
|
|
|
|
local botpos = vector.add(pos, minetest.facedir_to_dir(dir))
|
|
|
|
|
|
|
|
if minetest.is_protected(botpos, placer:get_player_name()) and
|
|
|
|
not minetest.check_player_privs(placer, "protection_bypass") then
|
|
|
|
minetest.record_protection_violation(botpos, placer:get_player_name())
|
|
|
|
return itemstack
|
|
|
|
end
|
|
|
|
|
|
|
|
local botdef = minetest.registered_nodes[minetest.get_node(botpos).name]
|
|
|
|
if not botdef or not botdef.buildable_to then
|
|
|
|
return itemstack
|
|
|
|
end
|
|
|
|
|
|
|
|
minetest.set_node(pos, {name = "bed:bed_foot", param2 = dir})
|
|
|
|
minetest.set_node(botpos, {name = "bed:bed_head", param2 = dir})
|
|
|
|
|
|
|
|
if not minetest.settings:get_bool("creative_mode") then
|
|
|
|
itemstack:take_item()
|
|
|
|
end
|
|
|
|
return itemstack
|
|
|
|
end,
|
2015-10-10 08:23:27 +02:00
|
|
|
|
2015-09-01 17:15:24 +02:00
|
|
|
on_destruct = function(pos)
|
2020-06-20 18:34:21 +02:00
|
|
|
local meta = minetest.get_meta(pos)
|
|
|
|
local name = meta:get_string("player")
|
|
|
|
local player = minetest.get_player_by_name(name)
|
|
|
|
if name ~= "" and player then
|
|
|
|
bed.userdata.temp[name].in_bed = false
|
|
|
|
take_player_from_bed(player)
|
|
|
|
end
|
|
|
|
|
2017-05-15 19:44:27 +02:00
|
|
|
local node = minetest.get_node(pos)
|
|
|
|
local dir = minetest.facedir_to_dir(node.param2)
|
|
|
|
local head_pos = vector.add(pos, dir)
|
|
|
|
if minetest.get_node(head_pos).name == "bed:bed_head" then
|
|
|
|
minetest.remove_node(head_pos)
|
|
|
|
end
|
|
|
|
end,
|
2015-10-10 08:23:27 +02:00
|
|
|
|
2019-09-04 00:15:38 +02:00
|
|
|
on_rightclick = function(pos, node, clicker, itemstack)
|
2017-05-15 19:44:27 +02:00
|
|
|
if not clicker:is_player() then
|
2019-09-04 00:15:38 +02:00
|
|
|
return itemstack
|
2017-05-15 19:44:27 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
local name = clicker:get_player_name()
|
|
|
|
local meta = minetest.get_meta(pos)
|
2019-09-04 00:15:38 +02:00
|
|
|
local put_pos = vector.add(pos, vector.divide(minetest.facedir_to_dir(node.param2), 2))
|
2017-05-15 19:44:27 +02:00
|
|
|
|
2019-09-04 01:01:02 +02:00
|
|
|
-- Clear player if player is not online
|
|
|
|
local playername_in_bed = meta:get_string("player")
|
|
|
|
if playername_in_bed ~= "" then
|
|
|
|
local player_in_bed = minetest.get_player_by_name(playername_in_bed)
|
|
|
|
if not player_in_bed then
|
|
|
|
meta:set_string("player", "")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2019-08-29 18:15:38 +02:00
|
|
|
if name == meta:get_string("player") then
|
2020-01-31 02:05:05 +01:00
|
|
|
bed.userdata.temp[name].in_bed = false
|
2015-10-11 18:13:20 +02:00
|
|
|
|
2017-05-15 19:44:27 +02:00
|
|
|
take_player_from_bed(clicker)
|
2015-10-11 18:13:20 +02:00
|
|
|
|
2017-05-15 19:44:27 +02:00
|
|
|
meta:set_string("player", "")
|
|
|
|
elseif meta:get_string("player") == "" and not default.player_attached[name]
|
2020-01-31 02:05:05 +01:00
|
|
|
and bed.userdata.temp[name].in_bed == false then
|
2019-09-03 21:07:55 +02:00
|
|
|
if not minetest.settings:get_bool("bed_enable", true) then
|
2019-09-04 00:15:38 +02:00
|
|
|
minetest.chat_send_player(name, minetest.colorize("#FFFF00", S("Sleeping is disabled.")))
|
|
|
|
return itemstack
|
|
|
|
end
|
|
|
|
|
|
|
|
local dir = minetest.facedir_to_dir(node.param2)
|
|
|
|
local above_posses = {
|
|
|
|
{x=pos.x, y=pos.y+1, z=pos.z},
|
|
|
|
vector.add({x=pos.x, y=pos.y+1, z=pos.z}, dir),
|
|
|
|
{x=pos.x, y=pos.y+2, z=pos.z},
|
|
|
|
vector.add({x=pos.x, y=pos.y+2, z=pos.z}, dir),
|
|
|
|
}
|
|
|
|
for a=1,#above_posses do
|
|
|
|
local apos = above_posses[a]
|
|
|
|
local anode = minetest.get_node(apos)
|
|
|
|
local adef = minetest.registered_nodes[anode.name]
|
|
|
|
if adef.walkable then
|
|
|
|
minetest.chat_send_player(name, minetest.colorize("#FFFF00", S("Not enough space to sleep!")))
|
|
|
|
return itemstack
|
|
|
|
end
|
2017-05-15 19:44:27 +02:00
|
|
|
end
|
2015-10-11 18:13:20 +02:00
|
|
|
|
2019-08-29 18:15:38 +02:00
|
|
|
-- No sleeping while moving
|
|
|
|
if vector.length(clicker:get_player_velocity()) > 0.001 then
|
2019-08-29 23:24:35 +02:00
|
|
|
minetest.chat_send_player(name, minetest.colorize("#FFFF00", S("You have to stop moving before going to bed!")))
|
2019-09-04 00:15:38 +02:00
|
|
|
return itemstack
|
2019-08-29 18:15:38 +02:00
|
|
|
end
|
|
|
|
|
2017-05-15 19:44:27 +02:00
|
|
|
put_pos.y = put_pos.y + 0.6
|
2015-10-11 18:13:20 +02:00
|
|
|
|
2017-05-15 19:44:27 +02:00
|
|
|
local yaw = 0
|
2015-10-11 18:13:20 +02:00
|
|
|
|
2017-05-15 19:44:27 +02:00
|
|
|
if node.param2 ~= 2 then
|
|
|
|
yaw = (node.param2 / 2.0) * math.pi
|
|
|
|
end
|
2015-10-11 18:13:20 +02:00
|
|
|
|
2020-01-31 02:05:05 +01:00
|
|
|
bed.userdata.temp[name].in_bed = true
|
2015-10-10 08:23:27 +02:00
|
|
|
|
2020-01-31 02:05:05 +01:00
|
|
|
bed.userdata.saved[name].spawn_yaw = yaw
|
|
|
|
bed.userdata.saved[name].spawn_pos = put_pos
|
2015-10-10 08:23:27 +02:00
|
|
|
|
2020-01-31 02:05:05 +01:00
|
|
|
bed.userdata.temp[name].node_pos = pos
|
2017-05-15 19:44:27 +02:00
|
|
|
|
|
|
|
put_player_in_bed(clicker)
|
|
|
|
|
|
|
|
meta:set_string("player", name)
|
|
|
|
end
|
2019-09-04 00:15:38 +02:00
|
|
|
return itemstack
|
2017-05-15 19:44:27 +02:00
|
|
|
end,
|
2015-09-30 19:09:59 +02:00
|
|
|
|
2015-10-10 08:23:27 +02:00
|
|
|
can_dig = function(pos)
|
2017-05-15 19:44:27 +02:00
|
|
|
return minetest.get_meta(pos):get_string("player") == ""
|
|
|
|
end
|
|
|
|
})
|
2015-09-01 17:15:24 +02:00
|
|
|
|
2017-05-12 04:29:55 +02:00
|
|
|
minetest.register_node(
|
2015-09-01 17:15:24 +02:00
|
|
|
"bed:bed_head",
|
|
|
|
{
|
|
|
|
drawtype = "nodebox",
|
|
|
|
paramtype = "light",
|
|
|
|
paramtype2 = "facedir",
|
2019-08-29 14:52:32 +02:00
|
|
|
is_ground_content = false,
|
2015-10-10 08:23:27 +02:00
|
|
|
pointable = false,
|
2020-06-20 18:34:21 +02:00
|
|
|
diggable = false,
|
2015-10-10 08:23:27 +02:00
|
|
|
tiles = {"bed_head.png", "default_wood.png", "bed_side.png"},
|
2021-02-04 22:08:51 +01:00
|
|
|
use_texture_alpha = "clip",
|
2015-09-01 17:15:24 +02:00
|
|
|
groups = {snappy = 1, choppy = 2, oddly_breakable_by_hand = 2, flammable = 3},
|
|
|
|
sounds = default.node_sound_wood_defaults(),
|
|
|
|
node_box = {
|
|
|
|
type = "fixed",
|
2015-10-10 08:23:27 +02:00
|
|
|
fixed = {-0.5, -0.5, -0.5, 0.5, 2/16, 0.5}
|
2020-06-20 18:34:21 +02:00
|
|
|
},
|
|
|
|
on_blast = function() end,
|
|
|
|
drop = "",
|
2017-05-15 19:44:27 +02:00
|
|
|
})
|
2015-09-01 17:15:24 +02:00
|
|
|
|
2017-05-12 04:29:55 +02:00
|
|
|
minetest.register_alias("bed:bed", "bed:bed_foot")
|
2015-09-01 17:15:24 +02:00
|
|
|
|
2017-05-16 20:31:46 +02:00
|
|
|
-- Crafting
|
|
|
|
|
2017-05-15 19:44:27 +02:00
|
|
|
crafting.register_craft(
|
2015-09-01 17:15:24 +02:00
|
|
|
{
|
|
|
|
output = "bed:bed",
|
2017-05-15 19:44:27 +02:00
|
|
|
items = {
|
|
|
|
"group:fuzzy 3",
|
|
|
|
"group:planks 3",
|
2015-09-01 17:15:24 +02:00
|
|
|
}
|
2017-05-15 19:44:27 +02:00
|
|
|
})
|
2015-09-01 17:15:24 +02:00
|
|
|
|
2017-05-16 20:31:46 +02:00
|
|
|
-- Player effects
|
|
|
|
|
2015-10-24 20:36:31 +02:00
|
|
|
player_effects.register_effect(
|
|
|
|
"inbed",
|
|
|
|
{
|
2019-08-29 17:39:51 +02:00
|
|
|
title = S("In bed"),
|
|
|
|
description = S("You're in a bed"),
|
2015-10-24 20:36:31 +02:00
|
|
|
duration = -1,
|
|
|
|
physics = {
|
|
|
|
speed = 0,
|
|
|
|
jump = 0,
|
2020-01-31 01:14:59 +01:00
|
|
|
},
|
2020-01-31 01:33:33 +01:00
|
|
|
save = false,
|
2020-01-31 01:14:59 +01:00
|
|
|
icon = "bed_effect.png",
|
2017-05-15 19:44:27 +02:00
|
|
|
})
|
2015-09-30 19:09:59 +02:00
|
|
|
|
2015-10-25 22:18:54 +01:00
|
|
|
-- Achievements
|
|
|
|
|
|
|
|
achievements.register_achievement(
|
|
|
|
"bedtime",
|
|
|
|
{
|
2019-08-28 17:31:41 +02:00
|
|
|
title = S("Bed Time"),
|
2019-09-02 14:54:29 +02:00
|
|
|
description = S("Craft a bed."),
|
2015-10-25 22:18:54 +01:00
|
|
|
times = 1,
|
2015-11-09 20:16:25 +01:00
|
|
|
craftitem = "bed:bed_foot",
|
2017-05-15 19:44:27 +02:00
|
|
|
})
|
2015-10-25 22:18:54 +01:00
|
|
|
|
2020-01-31 02:05:05 +01:00
|
|
|
minetest.register_lbm({
|
|
|
|
label = "Reset beds",
|
|
|
|
name = "bed:reset_beds",
|
|
|
|
nodenames = {"bed:bed_foot"},
|
|
|
|
run_at_every_load = true,
|
|
|
|
action = function(pos, node)
|
|
|
|
local meta = minetest.get_meta(pos)
|
|
|
|
meta:set_string("player", "")
|
|
|
|
end,
|
|
|
|
})
|
|
|
|
|
2015-10-04 06:25:26 +02:00
|
|
|
default.log("mod:bed", "loaded")
|