2019-05-27 02:02:29 +02:00
|
|
|
-- formerly lrfurn coffee table component
|
2017-01-29 22:41:03 +01:00
|
|
|
|
2019-04-21 17:25:21 +02:00
|
|
|
local S = homedecor.gettext
|
2017-01-29 22:41:03 +01:00
|
|
|
|
2019-05-27 02:02:29 +02:00
|
|
|
local fdir_to_right = {
|
|
|
|
{ 1, 0 },
|
|
|
|
{ 0, -1 },
|
|
|
|
{ -1, 0 },
|
|
|
|
{ 0, 1 },
|
|
|
|
}
|
|
|
|
|
|
|
|
local function check_right(pos, fdir, long, placer)
|
|
|
|
if not fdir or fdir > 3 then fdir = 0 end
|
|
|
|
|
|
|
|
local pos2 = { x = pos.x + fdir_to_right[fdir+1][1], y=pos.y, z = pos.z + fdir_to_right[fdir+1][2] }
|
|
|
|
local pos3 = { x = pos.x + fdir_to_right[fdir+1][1] * 2, y=pos.y, z = pos.z + fdir_to_right[fdir+1][2] * 2 }
|
|
|
|
|
|
|
|
local node2 = minetest.get_node(pos2)
|
|
|
|
if node2 and node2.name ~= "air" then
|
|
|
|
return false
|
|
|
|
elseif minetest.is_protected(pos2, placer:get_player_name()) then
|
|
|
|
if not long then
|
|
|
|
minetest.chat_send_player(placer:get_player_name(), S("Someone else owns the spot where other end goes!"))
|
|
|
|
else
|
|
|
|
minetest.chat_send_player(placer:get_player_name(), S("Someone else owns the spot where the middle or far end goes!"))
|
|
|
|
end
|
|
|
|
return false
|
|
|
|
end
|
|
|
|
|
|
|
|
if long then
|
|
|
|
local node3 = minetest.get_node(pos3)
|
|
|
|
if node3 and node3.name ~= "air" then
|
|
|
|
return false
|
|
|
|
elseif minetest.is_protected(pos3, placer:get_player_name()) then
|
|
|
|
minetest.chat_send_player(placer:get_player_name(), S("Someone else owns the spot where the other end goes!"))
|
|
|
|
return false
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
return true
|
|
|
|
end
|
|
|
|
|
2017-02-22 22:38:19 +01:00
|
|
|
minetest.register_alias("lrfurn:coffeetable_back", "lrfurn:coffeetable")
|
|
|
|
minetest.register_alias("lrfurn:coffeetable_front", "air")
|
|
|
|
|
2019-05-27 02:02:29 +02:00
|
|
|
minetest.register_node(":lrfurn:coffeetable", {
|
2017-01-29 22:41:03 +01:00
|
|
|
description = S("Coffee Table"),
|
2014-07-19 01:37:08 +02:00
|
|
|
drawtype = "nodebox",
|
|
|
|
tiles = {"lrfurn_coffeetable_back.png", "lrfurn_coffeetable_back.png", "lrfurn_coffeetable_back.png", "lrfurn_coffeetable_back.png", "lrfurn_coffeetable_back.png", "lrfurn_coffeetable_back.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 = {
|
|
|
|
--legs
|
2017-02-22 22:38:19 +01:00
|
|
|
{ -0.375, -0.5, -0.375, -0.3125, -0.0625, -0.3125 },
|
|
|
|
{ 0.3125, -0.5, -0.375, 0.375, -0.0625, -0.3125 },
|
|
|
|
{ -0.375, -0.5, 1.3125, -0.3125, -0.0625, 1.375 },
|
|
|
|
{ 0.3125, -0.5, 1.3125, 0.375, -0.0625, 1.375 },
|
2014-07-19 01:37:08 +02:00
|
|
|
--tabletop
|
2017-02-22 22:38:19 +01:00
|
|
|
{-0.4375, -0.0625, -0.4375, 0.4375, 0, 1.4375},
|
2014-07-19 01:37:08 +02:00
|
|
|
}
|
|
|
|
},
|
|
|
|
selection_box = {
|
|
|
|
type = "fixed",
|
|
|
|
fixed = {
|
|
|
|
{-0.4375, -0.5, -0.4375, 0.4375, 0.0, 1.4375},
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
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
|
2014-11-30 18:21:28 +01:00
|
|
|
local node = minetest.get_node(pos)
|
2017-02-22 22:38:19 +01:00
|
|
|
local fdir = node.param2
|
2015-07-21 11:08:40 +02:00
|
|
|
|
2019-05-27 02:02:29 +02:00
|
|
|
if check_right(pos, fdir, false, placer) then
|
2017-02-22 22:38:19 +01:00
|
|
|
minetest.set_node(pos, { name = node.name, param2 = (fdir + 1) % 4 })
|
2015-07-21 11:08:40 +02:00
|
|
|
else
|
2017-01-29 22:41:03 +01:00
|
|
|
minetest.chat_send_player(placer:get_player_name(),
|
2017-02-22 22:38:19 +01:00
|
|
|
S("No room to place the coffee table!"))
|
2015-07-21 11:08:40 +02:00
|
|
|
minetest.set_node(pos, {name = "air"})
|
|
|
|
return true
|
2014-07-19 01:37:08 +02:00
|
|
|
end
|
|
|
|
end,
|
|
|
|
})
|
|
|
|
|
2018-10-25 18:43:14 +02:00
|
|
|
minetest.register_craft({
|
|
|
|
output = "lrfurn:coffeetable",
|
|
|
|
type = "shapeless",
|
|
|
|
recipe = {
|
|
|
|
"lrfurn:endtable",
|
|
|
|
"lrfurn:endtable"
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
2014-07-19 01:37:08 +02:00
|
|
|
minetest.register_craft({
|
|
|
|
output = "lrfurn:coffeetable",
|
|
|
|
recipe = {
|
|
|
|
{"", "", "", },
|
|
|
|
{"stairs:slab_wood", "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:coffeetable",
|
|
|
|
recipe = {
|
|
|
|
{"", "", "", },
|
|
|
|
{"moreblocks:slab_wood", "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
|
|
|
}
|
|
|
|
})
|
|
|
|
|
2017-05-13 09:15:26 +02:00
|
|
|
if minetest.settings:get("log_mods") then
|
2017-01-29 22:41:03 +01:00
|
|
|
minetest.log("action", "[lrfurn/coffeetable] "..S("Loaded!"))
|
2014-07-19 01:37:08 +02:00
|
|
|
end
|