2015-09-23 07:29:06 +02:00
|
|
|
|
2014-07-19 01:37:08 +02:00
|
|
|
|
2015-04-30 23:52:23 +02:00
|
|
|
local sofa_sbox = {
|
2015-04-07 23:28:28 +02:00
|
|
|
type = "fixed",
|
|
|
|
fixed = {-0.5, -0.5, -0.5, 0.5, 0.5, 1.5}
|
|
|
|
}
|
|
|
|
|
2015-04-30 23:52:23 +02:00
|
|
|
local sofa_cbox = {
|
|
|
|
type = "fixed",
|
|
|
|
fixed = {
|
|
|
|
{-0.5, -0.5, -0.5, 0.5, 0, 1.5 },
|
|
|
|
{-0.5, -0.5, 0.5, -0.4, 0.5, 1.5 }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-09-23 07:29:06 +02:00
|
|
|
for i in ipairs(lrfurn.colors) do
|
|
|
|
local colour = lrfurn.colors[i][1]
|
|
|
|
local hue = lrfurn.colors[i][2]
|
2014-07-19 01:37:08 +02:00
|
|
|
|
2015-04-07 03:35:25 +02:00
|
|
|
minetest.register_node("lrfurn:sofa_"..colour, {
|
2015-09-23 07:29:06 +02:00
|
|
|
description = "Sofa ("..colour..")",
|
2015-04-07 03:35:25 +02:00
|
|
|
drawtype = "mesh",
|
|
|
|
mesh = "lrfurn_sofa_short.obj",
|
|
|
|
tiles = {
|
2015-09-23 07:29:06 +02:00
|
|
|
"lrfurn_bg_white.png^[colorize:"..hue.."^lrfurn_sofa_overlay.png",
|
2015-04-07 03:35:25 +02:00
|
|
|
"lrfurn_sofa_bottom.png"
|
|
|
|
},
|
2014-07-19 01:37:08 +02:00
|
|
|
paramtype = "light",
|
|
|
|
paramtype2 = "facedir",
|
2015-04-30 23:52:23 +02:00
|
|
|
groups = {snappy=3},
|
2014-07-19 01:37:08 +02:00
|
|
|
sounds = default.node_sound_wood_defaults(),
|
2015-04-30 23:52:23 +02:00
|
|
|
selection_box = sofa_sbox,
|
|
|
|
node_box = sofa_cbox,
|
2015-05-14 12:25:11 +02:00
|
|
|
on_rotate = screwdriver.disallow,
|
2015-07-21 11:08:40 +02:00
|
|
|
|
|
|
|
after_place_node = function(pos, placer, itemstack, pointed_thing)
|
|
|
|
if minetest.is_protected(pos, placer:get_player_name()) then return true end
|
|
|
|
|
2015-04-07 04:49:46 +02:00
|
|
|
local fdir = minetest.dir_to_facedir(placer:get_look_dir(), false)
|
2014-07-19 01:37:08 +02:00
|
|
|
|
2015-07-21 11:08:40 +02:00
|
|
|
if lrfurn.check_forward(pos, fdir, false, placer) then
|
2015-04-07 04:49:46 +02:00
|
|
|
minetest.set_node(pos, {name = "lrfurn:sofa_"..colour, param2 = fdir})
|
|
|
|
itemstack:take_item()
|
|
|
|
else
|
|
|
|
minetest.chat_send_player(placer:get_player_name(), "No room to place the sofa!")
|
2015-07-21 11:08:40 +02:00
|
|
|
minetest.set_node(pos, { name = "air" })
|
|
|
|
|
2015-04-07 04:49:46 +02:00
|
|
|
end
|
|
|
|
return itemstack
|
|
|
|
end,
|
2016-07-31 01:17:23 +02:00
|
|
|
on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
|
2014-07-19 01:37:08 +02:00
|
|
|
if not clicker:is_player() then
|
2016-07-31 01:17:23 +02:00
|
|
|
return itemstack
|
2014-07-19 01:37:08 +02:00
|
|
|
end
|
|
|
|
pos.y = pos.y-0.5
|
|
|
|
clicker:setpos(pos)
|
|
|
|
clicker:set_hp(20)
|
2016-07-31 01:17:23 +02:00
|
|
|
return itemstack
|
2014-07-19 01:37:08 +02:00
|
|
|
end
|
|
|
|
})
|
2015-01-20 23:59:50 +01:00
|
|
|
|
2015-04-07 03:35:25 +02:00
|
|
|
minetest.register_alias("lrfurn:sofa_left_"..colour, "air")
|
|
|
|
minetest.register_alias("lrfurn:sofa_right_"..colour, "lrfurn:sofa_"..colour)
|
2014-07-19 01:37:08 +02:00
|
|
|
|
|
|
|
minetest.register_craft({
|
|
|
|
output = "lrfurn:sofa_"..colour,
|
|
|
|
recipe = {
|
|
|
|
{"wool:"..colour, "wool:"..colour, "", },
|
|
|
|
{"stairs:slab_wood", "stairs:slab_wood", "", },
|
2014-07-31 00:19:42 +02:00
|
|
|
{"group:stick", "group:stick", "", }
|
2014-07-19 01:37:08 +02:00
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
minetest.register_craft({
|
|
|
|
output = "lrfurn:sofa_"..colour,
|
|
|
|
recipe = {
|
|
|
|
{"wool:"..colour, "wool:"..colour, "", },
|
|
|
|
{"moreblocks:slab_wood", "moreblocks:slab_wood", "", },
|
2014-07-31 00:19:42 +02:00
|
|
|
{"group:stick", "group:stick", "", }
|
2014-07-19 01:37:08 +02:00
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
if minetest.setting_get("log_mods") then
|
|
|
|
minetest.log("action", "sofas loaded")
|
|
|
|
end
|