added papyrus_bed

master
cornernote 2012-08-09 17:46:56 +09:30
parent e90d0a2fb7
commit 4dda01351b
16 changed files with 247 additions and 0 deletions

View File

@ -0,0 +1,25 @@
************************************
* PAPYRUS_BED MOD for MINETEST-C55 *
************************************
by Ragnarok AKA Vibender, http://vibender.com
based on modified beds mod by PilzAdam
License:
Sourcecode: WTFPL, http://sam.zoy.org/wtfpl/
Graphics & Sounds: CC-BY-NC-ND, http://creativecommons.org/licenses/by-nc-nd/3.0/
Crafting recipe:
PAPER | PAPYRUS | PAPYRUS
------+---------+--------
WOOD | WOOD | WOOD
------+---------+--------
STICK | | STICK

View File

@ -0,0 +1 @@
default

221
mods/papyrus_bed/init.lua Normal file
View File

@ -0,0 +1,221 @@
local player_ges = 0
local player_in_bed = 0
minetest.register_node("papyrus_bed:bed_bottom", {
description = "Papyrus bed",
drawtype = "nodebox",
tiles = {"papyrus_bed_bottom_above.png", "papyrus_bed_bottom_below.png", "papyrus_bed_bottom_side_right.png", "papyrus_bed_bottom_side_left.png", "papyrus_bed_brackets.png", "papyrus_bed_bottom_bottom.png"},
paramtype = "light",
paramtype2 = "facedir",
groups = {snappy=1,choppy=2,oddly_breakable_by_hand=2,flammable=3},
sounds = default.node_sound_wood_defaults(),
node_box = {
type = "fixed",
fixed = {
-- bedspread
{-0.5, 0.3125, -0.5, 0.5, 0.4375, 0.5},
-- frame and mattress
{-0.5, -0.3125, -0.5, 0.5, 0.3125, 0.5},
-- brackets
{-0.5, -0.5, -0.5, -0.3125, -0.3125, -0.3125},
{0.3125, -0.5, -0.5, 0.5, -0.3125, -0.3125},
}
},
selection_box = {
type = "fixed",
fixed = {
{-0.5, -0.5, -0.5, 0.5, 0.5, 1.5},
}
},
on_construct = function(pos)
local node = minetest.env:get_node(pos)
local param2 = node.param2
if param2 == 0 then
node.name = "papyrus_bed:bed_top"
pos.z = pos.z+1
minetest.env:set_node(pos, node)
elseif param2 == 1 then
node.name = "papyrus_bed:bed_top"
pos.x = pos.x+1
minetest.env:set_node(pos, node)
elseif param2 == 2 then
node.name = "papyrus_bed:bed_top"
pos.z = pos.z-1
minetest.env:set_node(pos, node)
elseif param2 == 3 then
node.name = "papyrus_bed:bed_top"
pos.x = pos.x-1
minetest.env:set_node(pos, node)
end
end,
on_destruct = function(pos)
local node = minetest.env:get_node(pos)
local param2 = node.param2
if param2 == 0 then
pos.z = pos.z+1
minetest.env:remove_node(pos)
elseif param2 == 1 then
pos.x = pos.x+1
minetest.env:remove_node(pos)
elseif param2 == 2 then
pos.z = pos.z-1
minetest.env:remove_node(pos)
elseif param2 == 3 then
pos.x = pos.x-1
minetest.env:remove_node(pos)
end
end,
on_punch = function(pos, node, puncher)
if not puncher:is_player() then
return
end
if puncher:get_wielded_item():get_name() == "" then
local meta = minetest.env:get_meta(pos)
local param2 = node.param2
if param2 == 0 then
pos.z = pos.z+1
elseif param2 == 1 then
pos.x = pos.x+1
elseif param2 == 2 then
pos.z = pos.z-1
elseif param2 == 3 then
pos.x = pos.x-1
end
if puncher:get_player_name() == meta:get_string("player") then
if param2 == 0 then
pos.x = pos.x-1
elseif param2 == 1 then
pos.z = pos.z+1
elseif param2 == 2 then
pos.x = pos.x+1
elseif param2 == 3 then
pos.z = pos.z-1
end
pos.y = pos.y-0.5
puncher:setpos(pos)
meta:set_string("player", "")
player_in_bed = player_in_bed-1
elseif meta:get_string("player") == "" then
pos.y = pos.y-0.5
puncher:setpos(pos)
meta:set_string("player", puncher:get_player_name())
player_in_bed = player_in_bed+1
end
end
end
})
minetest.register_node("papyrus_bed:bed_top", {
drawtype = "nodebox",
tiles = {"papyrus_bed_top_above.png", "papyrus_bed_top_below.png", "papyrus_bed_top_side_right.png", "papyrus_bed_top_side_left.png", "papyrus_bed_top_top.png", "papyrus_bed_brackets.png"},
paramtype = "light",
paramtype2 = "facedir",
groups = {snappy=1,choppy=2,oddly_breakable_by_hand=2,flammable=3},
sounds = default.node_sound_wood_defaults(),
node_box = {
type = "fixed",
fixed = {
-- headboard
{-0.5, 0.3125, 0.4375, 0.5, 0.5, 0.5},
-- pillow
{-0.34375, 0.3125, 0.0, 0.34375, 0.375, 0.375},
-- bedspread
{-0.5, 0.3125, -0.5, 0.5, 0.4375, 0.0},
-- frame and mattress
{-0.5, -0.3125, -0.5, 0.5, 0.3125, 0.5},
-- brackets
{-0.5, -0.5, 0.3125, -0.3125, -0.3125, 0.5},
{0.3125, -0.5, 0.3125, 0.5, -0.3125, 0.5},
}
},
selection_box = {
type = "fixed",
fixed = {
{0, 0, 0, 0, 0, 0},
}
},
})
minetest.register_alias("papyrus_bed:bed", "papyrus_bed:bed_bottom")
minetest.register_craft({
output = "papyrus_bed:bed",
recipe = {
{"default:paper", "default:papyrus", "default:papyrus", },
{"default:wood", "default:wood", "default:wood", },
{"default:stick", "", "default:stick", }
}
})
minetest.register_on_joinplayer(function(pl)
player_ges = player_ges+1
end)
minetest.register_on_leaveplayer(function(pl)
player_ges = player_ges-1
end)
local timer = 0
local wait = false
minetest.register_globalstep(function(dtime)
if timer<10 then
timer = timer+dtime
end
timer = 0
if player_ges == player_in_bed and player_ges ~= 0 then
if minetest.env:get_timeofday() < 0.2 or minetest.env:get_timeofday() > 0.805 then
if not wait then
-- sound playback
minetest.sound_play("papyrus_bed_snoring",{"papyrus_bed:bed", gain = 0.9, max_hear_distance = 10,})
-- text message
minetest.chat_send_all("Good night!")
minetest.after(2, function()
minetest.env:set_timeofday(0.23)
wait = false
end)
wait = true
end
end
end
end)
minetest.register_abm({
nodenames = {"papyrus_bed:bed_bottom"},
interval = 1,
chance = 1,
action = function(pos, node)
local meta = minetest.env:get_meta(pos)
if meta:get_string("player") ~= "" then
local param2 = node.param2
if param2 == 0 then
pos.z = pos.z+1
elseif param2 == 1 then
pos.x = pos.x+1
elseif param2 == 2 then
pos.z = pos.z-1
elseif param2 == 3 then
pos.x = pos.x-1
end
local player = minetest.env:get_player_by_name(meta:get_string("player"))
if player == nil then
meta:set_string("player", "")
player_in_bed = player_in_bed-1
return
end
local player_pos = player:getpos()
player_pos.x = math.floor(0.5+player_pos.x)
player_pos.y = math.floor(0.5+player_pos.y)
player_pos.z = math.floor(0.5+player_pos.z)
if pos.x ~= player_pos.x or pos.y ~= player_pos.y or pos.z ~= player_pos.z then
meta:set_string("player", "")
player_in_bed = player_in_bed-1
return
end
end
end
})

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.9 KiB

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 312 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 922 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 521 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 924 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB