2019-05-27 02:02:29 +02:00
|
|
|
-- formerly lrfurn coffee table component
|
2017-01-29 22:41:03 +01:00
|
|
|
|
2020-08-05 00:42:05 +02:00
|
|
|
local S = minetest.get_translator("homedecor_tables")
|
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
|
2020-08-05 00:42:05 +02:00
|
|
|
minetest.chat_send_player(placer:get_player_name(), S("Someone else owns the spot where the other end goes!"))
|
2019-05-27 02:02:29 +02:00
|
|
|
else
|
2020-08-05 00:42:05 +02:00
|
|
|
minetest.chat_send_player(placer:get_player_name(),
|
|
|
|
S("Someone else owns the spot where the middle or far end goes!"))
|
2019-05-27 02:02:29 +02:00
|
|
|
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",
|
2020-08-05 00:42:05 +02:00
|
|
|
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"
|
|
|
|
},
|
2014-07-19 01:37:08 +02:00
|
|
|
paramtype = "light",
|
|
|
|
paramtype2 = "facedir",
|
2022-02-07 14:18:17 +01:00
|
|
|
use_texture_alpha = "blend",
|
2022-11-30 23:48:28 +01:00
|
|
|
groups = {snappy=1,choppy=2,oddly_breakable_by_hand=2,flammable=3, axey=5},
|
2024-03-01 00:49:24 +01:00
|
|
|
is_ground_content = false,
|
2022-11-30 23:48:28 +01:00
|
|
|
_mcl_hardness=1.6,
|
2022-05-03 21:21:14 +02:00
|
|
|
_sound_def = {
|
|
|
|
key = "node_sound_wood_defaults",
|
|
|
|
},
|
2014-07-19 01:37:08 +02:00
|
|
|
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 = {
|
|
|
|
{"", "", "", },
|
2022-05-03 21:21:14 +02:00
|
|
|
{homedecor.materials.slab_wood, homedecor.materials.slab_wood, homedecor.materials.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
|
2020-08-05 00:42:05 +02:00
|
|
|
minetest.log("action", "[lrfurn/coffeetable] Loaded!")
|
2014-07-19 01:37:08 +02:00
|
|
|
end
|