1
0
mirror of https://github.com/mt-mods/homedecor_modpack.git synced 2024-11-17 23:58:30 +01:00
homedecor_modpack/homedecor_tables/coffeetable.lua

127 lines
3.5 KiB
Lua
Raw Normal View History

-- formerly lrfurn coffee table component
2017-01-29 22:41:03 +01:00
local S = minetest.get_translator("homedecor_tables")
2017-01-29 22:41:03 +01: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 the 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
minetest.register_alias("lrfurn:coffeetable_back", "lrfurn:coffeetable")
minetest.register_alias("lrfurn:coffeetable_front", "air")
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"
},
2014-07-19 01:37:08 +02:00
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
{ -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
{-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},
}
},
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)
local fdir = node.param2
if check_right(pos, fdir, false, placer) then
minetest.set_node(pos, { name = node.name, param2 = (fdir + 1) % 4 })
else
2017-01-29 22:41:03 +01:00
minetest.chat_send_player(placer:get_player_name(),
S("No room to place the coffee table!"))
minetest.set_node(pos, {name = "air"})
return true
2014-07-19 01:37:08 +02:00
end
end,
})
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", },
{"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", },
{"group:stick", "", "group:stick", }
2014-07-19 01:37:08 +02:00
}
})
if minetest.settings:get("log_mods") then
minetest.log("action", "[lrfurn/coffeetable] Loaded!")
2014-07-19 01:37:08 +02:00
end