1
0
mirror of https://github.com/mt-mods/homedecor_modpack.git synced 2024-12-23 00:20:17 +01:00
homedecor_modpack/homedecor/tables.lua

203 lines
5.8 KiB
Lua
Raw Normal View History

2017-01-30 00:12:02 +01:00
local S = homedecor_i18n.gettext
-- Various kinds of tables
2013-12-15 20:07:36 +01:00
local materials = {
2017-02-16 03:53:52 +01:00
{ "glass",
2017-01-24 21:43:20 +01:00
S("Small square glass table"),
S("Small round glass table"),
S("Large glass table piece"),
},
{ "wood",
S("Small square wooden table"),
S("Small round wooden table"),
S("Large wooden table piece"),
}
}
2014-12-26 03:40:56 +01:00
local tables_cbox = {
type = "fixed",
fixed = { -0.5, -0.5, -0.5, 0.5, -0.4375, 0.5 },
}
2017-01-24 21:43:20 +01:00
for i, mat in ipairs(materials) do
local m, small_s, small_r, large = unpack(mat)
local s
if m == "glass" then
s = default.node_sound_glass_defaults()
else
s = default.node_sound_wood_defaults()
end
-- small square tables
homedecor.register(m.."_table_small_square", {
2017-01-24 21:43:20 +01:00
description = small_s,
2014-12-14 19:22:44 +01:00
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,
2014-12-26 03:40:56 +01:00
selection_box = tables_cbox,
collision_box = tables_cbox,
on_place = minetest.rotate_node
})
-- small round tables
homedecor.register(m..'_table_small_round', {
2017-01-24 21:43:20 +01:00
description = small_r,
2014-12-14 02:31:57 +01:00
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,
2014-12-26 03:40:56 +01:00
selection_box = tables_cbox,
collision_box = tables_cbox,
on_place = minetest.rotate_node
})
-- Large square table pieces
homedecor.register(m..'_table_large', {
2017-01-24 21:43:20 +01:00
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 },
},
2014-12-26 03:40:56 +01:00
selection_box = tables_cbox,
on_place = minetest.rotate_node
})
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')
end
-- conversion routines for old non-6dfacedir tables
local tlist_s = {}
local tlist_t = {}
local dirs2 = { 9, 18, 7, 12 }
2014-12-14 02:31:57 +01:00
for i in ipairs(materials) do
local m = materials[i][1]
table.insert(tlist_s, "homedecor:"..m.."_table_large_s")
table.insert(tlist_s, "homedecor:"..m.."_table_small_square_s")
table.insert(tlist_s, "homedecor:"..m.."_table_small_round_s")
table.insert(tlist_t, "homedecor:"..m.."_table_large_t")
table.insert(tlist_t, "homedecor:"..m.."_table_small_square_t")
table.insert(tlist_t, "homedecor:"..m.."_table_small_round_t")
end
minetest.register_abm({
nodenames = tlist_s,
interval = 1,
chance = 1,
action = function(pos, node, active_object_count, active_object_count_wider)
local newnode = string.sub(node.name, 1, -3) -- strip the "_s" from the name
local fdir = node.param2 or 0
2015-03-05 23:10:27 +01:00
minetest.set_node(pos, {name = newnode, param2 = dirs2[fdir+1]})
end
})
minetest.register_abm({
nodenames = tlist_t,
interval = 1,
chance = 1,
action = function(pos, node, active_object_count, active_object_count_wider)
local newnode = string.sub(node.name, 1, -3) -- strip the "_t" from the name
minetest.set_node(pos, { name = newnode, param2 = 20 })
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
2017-01-24 21:43:20 +01:00
-- local above
materials = {
{ "brass", S("brass") },
{ "wrought_iron", S("wrought iron") },
}
2015-02-28 10:14:46 +01:00
for _, t in ipairs(materials) do
2017-01-24 21:43:20 +01:00
local name, desc = unpack(t)
homedecor.register("table_legs_"..name, {
description = S("Table Legs (@1)", desc),
drawtype = "plantlike",
2017-01-24 21:43:20 +01:00
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},
2015-04-29 14:14:36 +02:00
sounds = default.node_sound_wood_defaults(),
selection_box = {
type = "fixed",
fixed = { -0.37, -0.5, -0.37, 0.37, 0.5, 0.37 }
},
})
2015-02-28 10:14:46 +01:00
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 }
},
})