auto-combine tabletops with legs

If the player places table legs, and then places a tabletop while
pointing at the legs (from any side), the table and legs will
automatically be combined into a single node that can then have
something placed on top like usual.

This also gets rid of those redundant "utility" table nodes, since
these have always basically just been a set of legs, and a copy
of the small square wood table.  Now they're merged into the above
feature, and aliased as appropriate.

Tecccccccccchhnically, wood legs should only have been allowed to
combine with wooden tabletops...  then I googled around a bit,
and found a number of glass tables with wooden legs that were
surprisingly similar to the in-game versions.
This commit is contained in:
Vanessa Dannenberg 2021-03-26 23:08:06 -04:00
parent 40cd59aa24
commit c70fb1a1ed
32 changed files with 1808 additions and 472 deletions

View File

@ -2,25 +2,58 @@
local S = minetest.get_translator("homedecor_tables")
local materials = {
-- Various kinds of table legs
local table_shapes = {"large_square", "small_square", "small_round"}
local tabletop_materials = {
{ "glass",
S("Small square glass table"),
S("Small round glass table"),
S("Large glass table piece"),
S("Small square glass tabletop"),
S("Small round glass tabletop"),
S("Large glass tabletop piece"),
},
{ "wood",
S("Small square wooden table"),
S("Small round wooden table"),
S("Large wooden table piece"),
S("Small square wooden tabletop"),
S("Small round wooden tabletop"),
S("Large wooden tabletop piece"),
}
}
leg_materials = {
{ "brass", S("brass") },
{ "wrought_iron", S("wrought iron") },
{ "wood", S("wood") }
}
for _, t in ipairs(leg_materials) do
local name, desc = unpack(t)
homedecor.register("table_legs_"..name, {
description = S("Table Legs (@1)", desc),
drawtype = "plantlike",
tiles = {"homedecor_table_legs_"..name..".png"},
inventory_image = "homedecor_table_legs_"..name..".png",
wield_image = "homedecor_table_legs_"..name..".png",
walkable = false,
groups = {snappy=3},
sounds = default.node_sound_wood_defaults(),
selection_box = {
type = "fixed",
fixed = { -0.37, -0.5, -0.37, 0.37, 0.5, 0.37 }
},
})
end
minetest.register_alias("homedecor:utility_table_legs", "homedecor:table_legs_wood")
minetest.register_alias("homedecor:utility_table_top", "homedecor:wood_table_small_square")
-- table tops and combined tables
local tables_cbox = {
type = "fixed",
fixed = { -0.5, -0.5, -0.5, 0.5, -0.4375, 0.5 },
}
for i, mat in ipairs(materials) do
for i, mat in ipairs(tabletop_materials) do
local m, small_s, small_r, large = unpack(mat)
local s
@ -30,138 +63,67 @@ for i, mat in ipairs(materials) do
s = default.node_sound_wood_defaults()
end
-- small square tables
for _, shape in ipairs(table_shapes) do
homedecor.register(m.."_table_small_square", {
description = small_s,
mesh = "homedecor_table_small_square.obj",
tiles = { 'homedecor_'..m..'_table_small_square.png' },
wield_image = 'homedecor_'..m..'_table_small_square_inv.png',
inventory_image = 'homedecor_'..m..'_table_small_square_inv.png',
groups = { snappy = 3 },
sounds = s,
selection_box = tables_cbox,
collision_box = tables_cbox,
on_place = minetest.rotate_node
})
homedecor.register(m.."_table_"..shape, {
description = shape.." "..m.." tabletop",
mesh = "homedecor_table_"..shape..".obj",
tiles = {
'homedecor_'..m..'_table_'..shape..'.png',
'homedecor_'..m..'_table_edges.png',
'homedecor_blanktile.png',
'homedecor_blanktile.png',
'homedecor_blanktile.png',
},
wield_image = 'homedecor_'..m..'_table_'..shape..'_inv.png',
groups = { snappy = 3 },
sounds = s,
selection_box = tables_cbox,
collision_box = tables_cbox,
on_place = function(itemstack, placer, pointed_thing)
local player_name = placer:get_player_name()
if minetest.is_protected(pointed_thing.under, player_name) then return end
local node = minetest.get_node(pointed_thing.under)
if string.find(node.name, "homedecor:table_legs") then
local newname = string.format("homedecor:%s_table_%s_with_%s_legs",
m, shape, string.sub(node.name, 22))
minetest.set_node(pointed_thing.under, {name = newname})
if not creative.is_enabled_for(player_name) then
itemstack:take_item()
return itemstack
end
else
return minetest.rotate_node(itemstack, placer, pointed_thing)
end
end
})
-- small round tables
for _, l in ipairs(leg_materials) do
local leg_mat, desc = unpack(l)
homedecor.register(m..'_table_small_round', {
description = small_r,
mesh = "homedecor_table_small_round.obj",
tiles = { "homedecor_"..m.."_table_small_round.png" },
wield_image = 'homedecor_'..m..'_table_small_round_inv.png',
inventory_image = 'homedecor_'..m..'_table_small_round_inv.png',
groups = { snappy = 3 },
sounds = s,
selection_box = tables_cbox,
collision_box = tables_cbox,
on_place = minetest.rotate_node
})
-- Large square table pieces
homedecor.register(m..'_table_large', {
description = large,
tiles = {
'homedecor_'..m..'_table_large_tb.png',
'homedecor_'..m..'_table_large_tb.png',
'homedecor_'..m..'_table_large_edges.png',
'homedecor_'..m..'_table_large_edges.png',
'homedecor_'..m..'_table_large_edges.png',
'homedecor_'..m..'_table_large_edges.png'
},
wield_image = 'homedecor_'..m..'_table_large_inv.png',
inventory_image = 'homedecor_'..m..'_table_large_inv.png',
groups = { snappy = 3 },
sounds = s,
node_box = {
type = "fixed",
fixed = { -0.5, -0.5, -0.5, 0.5, -0.4375, 0.5 },
},
selection_box = tables_cbox,
on_place = minetest.rotate_node
})
homedecor.register(string.format("%s_table_%s_with_%s_legs", m, shape, leg_mat), {
description = string.format("%s %s table with %s legs", shape, m, leg_mat),
mesh = "homedecor_table_"..shape..".obj",
tiles = {
'homedecor_blanktile.png',
'homedecor_blanktile.png',
'homedecor_'..m..'_table_'..shape..'.png',
'homedecor_'..m..'_table_edges.png',
"homedecor_table_legs_"..leg_mat..".png",
},
groups = { snappy = 3 },
sounds = s,
})
end
end
minetest.register_alias('homedecor:'..m..'_table_large_b', 'homedecor:'..m..'_table_large')
minetest.register_alias('homedecor:'..m..'_table_small_square_b', 'homedecor:'..m..'_table_small_square')
minetest.register_alias('homedecor:'..m..'_table_small_round_b', 'homedecor:'..m..'_table_small_round')
minetest.register_alias('homedecor:'..m..'_table_large', 'homedecor:'..m..'_table_large_square')
end
-- other tables
homedecor.register("utility_table_top", {
description = S("Utility Table"),
tiles = {
'homedecor_utility_table_tb.png',
'homedecor_utility_table_tb.png',
'homedecor_utility_table_edges.png',
'homedecor_utility_table_edges.png',
'homedecor_utility_table_edges.png',
'homedecor_utility_table_edges.png'
},
wield_image = 'homedecor_utility_table_tb.png',
inventory_image = 'homedecor_utility_table_tb.png',
groups = { snappy = 3 },
sounds = default.node_sound_wood_defaults(),
paramtype2 = "wallmounted",
node_box = {
type = "wallmounted",
wall_bottom = { -0.5, -0.5, -0.5, 0.5, -0.4375, 0.5 },
wall_top = { -0.5, 0.4375, -0.5, 0.5, 0.5, 0.5 },
wall_side = { -0.5, -0.5, -0.5, -0.4375, 0.5, 0.5 },
},
selection_box = {
type = "wallmounted",
wall_bottom = { -0.5, -0.5, -0.5, 0.5, -0.4375, 0.5 },
wall_top = { -0.5, 0.4375, -0.5, 0.5, 0.5, 0.5 },
wall_side = { -0.5, -0.5, -0.5, -0.4375, 0.5, 0.5 },
},
})
-- Various kinds of table legs
-- local above
materials = {
{ "brass", S("brass") },
{ "wrought_iron", S("wrought iron") },
}
for _, t in ipairs(materials) do
local name, desc = unpack(t)
homedecor.register("table_legs_"..name, {
description = S("Table Legs (@1)", desc),
drawtype = "plantlike",
tiles = {"homedecor_table_legs_"..name..".png"},
inventory_image = "homedecor_table_legs_"..name..".png",
wield_image = "homedecor_table_legs_"..name..".png",
walkable = false,
groups = {snappy=3},
sounds = default.node_sound_wood_defaults(),
selection_box = {
type = "fixed",
fixed = { -0.37, -0.5, -0.37, 0.37, 0.5, 0.37 }
},
})
end
homedecor.register("utility_table_legs", {
description = S("Legs for Utility Table"),
drawtype = "plantlike",
tiles = { 'homedecor_utility_table_legs.png' },
inventory_image = 'homedecor_utility_table_legs_inv.png',
wield_image = 'homedecor_utility_table_legs.png',
walkable = false,
groups = { snappy = 3 },
sounds = default.node_sound_wood_defaults(),
selection_box = {
type = "fixed",
fixed = { -0.37, -0.5, -0.37, 0.37, 0.5, 0.37 }
},
})
-- crafting
minetest.register_craft( {
@ -266,7 +228,20 @@ minetest.register_craft({
burntime = 30,
})
for _, shape in ipairs (table_shapes) do
for _, leg in ipairs(leg_materials) do
for _, mat in ipairs(tabletop_materials) do
minetest.register_craft({
output = "homedecor:"..mat[1].."_table_"..shape.."_with_"..leg[1].."_legs",
type = "shapeless",
recipe = {
"homedecor:"..mat[1].."_table_"..shape,
"homedecor:table_legs_"..leg[1]
},
})
end
end
end
-- recycling
@ -329,3 +304,4 @@ minetest.register_craft({
"homedecor:wood_table_large"
}
})

View File

@ -1,3 +1,4 @@
name = homedecor_tables
description = Homedecor mod: tables
depends = homedecor_common, default, basic_materials
optional_depends = creative

View File

@ -0,0 +1,107 @@
# Blender v2.83.5 OBJ File: 'homedecor table with legs.blend'
# www.blender.org
o Cube_Cube.001
v -0.500000 -0.500000 0.500000
v 0.500000 -0.500000 -0.500000
v 0.500000 0.500000 0.500000
v 0.500000 0.500000 -0.500000
v -0.500000 0.437500 -0.500000
v -0.353553 -0.500000 0.353554
v -0.353553 0.437515 0.353554
v 0.353553 -0.500000 -0.353553
v 0.353553 0.437515 -0.353553
v 0.500000 -0.500000 0.500000
v 0.500000 -0.437500 -0.500000
v 0.500000 -0.437500 0.500000
v -0.500000 -0.437500 -0.500000
v -0.500000 -0.500000 -0.500000
v -0.500000 -0.437500 0.500000
v 0.500000 0.437500 -0.500000
v 0.500000 0.437500 0.500000
v -0.500000 0.500000 -0.500000
v -0.500000 0.437500 0.500000
v -0.500000 0.500000 0.500000
v 0.353553 -0.500000 0.353554
v 0.353553 0.437515 0.353554
v -0.353553 -0.500000 -0.353553
v -0.353553 0.437515 -0.353553
vt -0.000000 -0.000000
vt 1.000000 -0.000000
vt 1.000000 0.500000
vt -0.000000 0.500000
vt 1.000000 1.000000
vt -0.000000 1.000000
vt -0.000000 0.500000
vt 1.000000 0.500000
vt -0.000000 1.000000
vt -0.000000 0.937500
vt 1.000000 0.937500
vt -0.000000 0.937500
vt 1.000000 0.937500
vt 1.000000 1.000000
vt 1.000000 1.000000
vt -0.000000 1.000000
vt -0.000000 0.937500
vt 1.000000 0.937500
vt 1.000000 1.000000
vt -0.000000 1.000000
vt -0.000000 0.937500
vt 1.000000 0.937500
vt -0.000000 0.500000
vt 1.000000 0.500000
vt 1.000000 1.000000
vt -0.000000 1.000000
vt 1.000000 -0.000000
vt 1.000000 0.500000
vt 0.000000 0.500000
vt 0.000000 -0.000000
vt -0.000000 1.000000
vt -0.000000 0.937500
vt 1.000000 0.937500
vt 1.000000 1.000000
vt -0.000000 1.000000
vt -0.000000 0.937500
vt 1.000000 0.937500
vt 1.000000 0.937500
vt 1.000000 1.000000
vt -0.000000 0.937500
vt -0.000000 1.000000
vt -0.000000 0.937500
vt 1.000000 0.937500
vt 1.000000 1.000000
vt -0.000000 0.000000
vt 1.000000 -0.000000
vt 1.000000 1.000000
vt 0.000000 1.000000
vt -0.000000 0.000000
vt 1.000000 -0.000000
vt 1.000000 1.000000
vt 0.000000 1.000000
vn 0.0000 -1.0000 0.0000
vn 0.0000 1.0000 0.0000
vn 1.0000 0.0000 0.0000
vn -1.0000 0.0000 0.0000
vn 0.0000 0.0000 1.0000
vn 0.0000 0.0000 -1.0000
vn 0.7071 0.0000 -0.7071
vn 0.7071 0.0000 0.7071
g Cube_Cube.001_top-bottom
s off
f 14/1/1 2/2/1 10/3/1 1/4/1
f 11/5/2 13/6/2 15/7/2 12/8/2
g Cube_Cube.001_edges
f 11/5/3 12/9/3 10/10/3 2/11/3
f 13/6/4 14/12/4 1/13/4 15/14/4
f 12/15/5 15/16/5 1/17/5 10/18/5
f 13/19/6 11/20/6 2/21/6 14/22/6
g Cube_Cube.001_top-bot_with_legs
f 20/23/2 3/24/2 4/25/2 18/26/2
f 16/27/1 17/28/1 19/29/1 5/30/1
g Cube_Cube.001_edges_with_legs
f 20/31/5 19/32/5 17/33/5 3/34/5
f 4/25/3 3/35/3 17/36/3 16/37/3
f 19/38/4 20/39/4 18/26/4 5/40/4
f 4/41/6 16/42/6 5/43/6 18/44/6
g Cube_Cube.001_legs
f 21/45/7 23/46/7 24/47/7 22/48/7
f 6/49/8 8/50/8 9/51/8 7/52/8

File diff suppressed because it is too large Load Diff

View File

@ -1,43 +1,139 @@
v 0.499 -0.499 -0.499
v 0.499 -0.499 0.499
v -0.499 -0.499 0.499
v -0.499 -0.499 -0.499
v 0.499 -0.469 -0.499
v 0.499 -0.469 0.499
v -0.499 -0.469 0.499
v -0.499 -0.469 -0.499
v 0.469 -0.437 -0.469
v 0.469 -0.437 0.469
v -0.469 -0.437 0.469
v -0.469 -0.437 -0.469
vt 0.5 0.029
vt 0.971 0.029
vt 0.971 0.5
vt 0.5 0.5
vt 0.015 0.985
vt 0.015 0.515
vt 0.029 0.529
vt 0.029 0.971
vt 0.985 0.5
vt 0.985 0.029
vt 0.5 0.515
vt 0.971 0.515
vt 0.485 0.029
vt 0.485 0.5
vt 0.971 0.015
vt 0.5 0.015
vt 0.471 0.971
vt 0.471 0.529
vt 0.485 0.515
vt 0.485 0.985
# Blender v2.83.5 OBJ File: 'homedecor small square table with legs.blend'
# www.blender.org
o Cube_Cube.001
v -0.500000 -0.500000 0.500000
v 0.500000 -0.500000 -0.500000
v -0.500000 0.437500 -0.500000
v -0.353553 -0.500000 0.353554
v -0.353553 0.437515 0.353554
v 0.353553 -0.500000 -0.353553
v 0.353553 0.437515 -0.353553
v 0.500000 -0.500000 0.500000
v -0.500000 -0.500000 -0.500000
v 0.500000 0.437500 -0.500000
v 0.500000 0.437500 0.500000
v -0.500000 0.437500 0.500000
v 0.353553 -0.500000 0.353554
v 0.353553 0.437515 0.353554
v -0.353553 -0.500000 -0.353553
v -0.353553 0.437515 -0.353553
v 0.468750 0.500000 0.468750
v 0.500000 0.468750 0.500000
v 0.500000 0.468750 -0.500000
v 0.468750 0.500000 -0.468750
v 0.500000 -0.468750 -0.500000
v 0.468750 -0.437500 -0.468750
v 0.500000 -0.468750 0.500000
v 0.468750 -0.437500 0.468750
v -0.500000 -0.468750 -0.500000
v -0.468750 -0.437500 -0.468750
v -0.468750 -0.437500 0.468750
v -0.500000 -0.468750 0.500000
v -0.468750 0.500000 -0.468750
v -0.500000 0.468750 -0.500000
v -0.468750 0.500000 0.468750
v -0.500000 0.468750 0.500000
vt -0.000000 -0.000000
vt 1.000000 -0.000000
vt 1.000000 0.500000
vt -0.000000 0.500000
vt 0.968750 0.984375
vt 0.031250 0.984375
vt 0.031250 0.515625
vt 0.968750 0.515625
vt 0.000000 0.500000
vt 1.000000 0.500000
vt 1.000000 1.000000
vt 0.000000 1.000000
vt 1.000000 0.968750
vt 0.000000 0.968750
vt 0.000000 0.937500
vt 1.000000 0.937500
vt 1.000000 0.968750
vt 0.000000 0.968750
vt 0.000000 0.937500
vt 1.000000 0.937500
vt 0.000000 0.968750
vt 0.000000 0.937500
vt 1.000000 0.937500
vt 1.000000 0.968750
vt 1.000000 0.968750
vt 0.000000 0.968750
vt 0.000000 0.937500
vt 1.000000 0.937500
vt 1.000000 -0.000000
vt 1.000000 0.500000
vt 0.000000 0.500000
vt 0.000000 -0.000000
vt 0.031250 0.515625
vt 0.968750 0.515625
vt 0.968750 0.984375
vt 0.031250 0.984375
vt 0.000000 1.000000
vt 0.000000 0.500000
vt 1.000000 0.500000
vt 1.000000 1.000000
vt 0.000000 0.968750
vt 0.000000 0.937500
vt 1.000000 0.937500
vt 1.000000 0.968750
vt 0.000000 0.968750
vt 0.000000 0.937500
vt 1.000000 0.937500
vt 1.000000 0.968750
vt 1.000000 0.937500
vt 1.000000 0.968750
vt 0.000000 0.968750
vt 0.000000 0.937500
vt 1.000000 0.968750
vt 0.000000 0.968750
vt 0.000000 0.937500
vt 1.000000 0.937500
vt -0.000000 0.000000
vt 1.000000 -0.000000
vt 1.000000 1.000000
vt 0.000000 1.000000
vt -0.000000 0.000000
vt 1.000000 -0.000000
vt 1.000000 1.000000
vt 0.000000 1.000000
vn 0.0000 -1.0000 0.0000
vn 0.0000 1.0000 0.0000
vn 0.0000 0.7071 0.7071
vn 0.7071 0.7071 0.0000
vn 0.0000 0.7071 -0.7071
vn -0.7071 0.7071 0.0000
vn 0.0000 0.0000 1.0000
vn 0.0000 0.0000 -1.0000
vn -1.0000 0.0000 0.0000
vn 1.0000 0.0000 0.0000
vn 0.7071 0.0000 -0.7071
vn 0.7071 0.0000 0.7071
g Cube_Cube.001_top-bottom
s off
f 1/1 2/2 3/3 4/4
f 8/5 7/6 11/7 12/8
f 1/9 5/3 6/2 2/10
f 2/11 6/4 7/3 3/12
f 3/13 7/1 8/4 4/14
f 5/15 1/2 4/1 8/16
f 9/17 12/8 11/7 10/18
f 7/6 6/19 10/18 11/7
f 5/20 8/5 12/8 9/17
f 6/19 5/20 9/17 10/18
f 9/1/1 2/2/1 8/3/1 1/4/1
f 22/5/2 26/6/2 27/7/2 24/8/2
f 24/8/3 27/7/3 28/9/3 23/10/3
f 22/5/4 24/8/4 23/10/4 21/11/4
f 26/6/5 22/5/5 21/11/5 25/12/5
f 27/7/6 26/6/6 25/12/6 28/9/6
g Cube_Cube.001_edges
f 23/13/7 28/14/7 1/15/7 8/16/7
f 25/17/8 21/18/8 2/19/8 9/20/8
f 25/21/9 9/22/9 1/23/9 28/24/9
f 21/25/10 23/26/10 8/27/10 2/28/10
g Cube_Cube.001_top-bot_with_legs
f 10/29/1 11/30/1 12/31/1 3/32/1
f 31/33/2 17/34/2 20/35/2 29/36/2
f 31/33/6 29/36/6 30/37/6 32/38/6
f 20/35/4 17/34/4 18/39/4 19/40/4
f 17/34/3 31/33/3 32/38/3 18/39/3
f 29/36/5 20/35/5 19/40/5 30/37/5
g Cube_Cube.001_edges_with_legs
f 32/41/7 12/42/7 11/43/7 18/44/7
f 19/45/8 10/46/8 3/47/8 30/48/8
f 12/49/9 32/50/9 30/51/9 3/52/9
f 19/53/10 18/54/10 11/55/10 10/56/10
g Cube_Cube.001_legs
f 13/57/11 15/58/11 16/59/11 14/60/11
f 4/61/12 6/62/12 7/63/12 5/64/12

Binary file not shown.

Before

Width:  |  Height:  |  Size: 74 B

View File

Before

Width:  |  Height:  |  Size: 189 B

After

Width:  |  Height:  |  Size: 189 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 604 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 315 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 146 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 241 B

After

Width:  |  Height:  |  Size: 597 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.8 KiB

After

Width:  |  Height:  |  Size: 713 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 358 B

After

Width:  |  Height:  |  Size: 642 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.8 KiB

After

Width:  |  Height:  |  Size: 334 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 331 B

After

Width:  |  Height:  |  Size: 476 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 357 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 325 B

After

Width:  |  Height:  |  Size: 439 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 465 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 338 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 576 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 204 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 465 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 652 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 529 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 573 B

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.1 KiB

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 982 B

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.1 KiB

After

Width:  |  Height:  |  Size: 901 B