2016-09-04 17:09:25 +02:00
|
|
|
local carpet_proto = {
|
|
|
|
drawtype = "nodebox",
|
|
|
|
paramtype = "light",
|
|
|
|
paramtype2 = "facedir",
|
|
|
|
node_box = {
|
|
|
|
type = "fixed",
|
|
|
|
fixed = {-0.5, -0.5, -0.5, 0.5, -0.45, 0.5}
|
2017-03-02 21:18:14 +01:00
|
|
|
},
|
|
|
|
groups = {
|
|
|
|
snappy = 2,
|
|
|
|
flammable = 3,
|
|
|
|
oddly_breakable_by_hand = 3,
|
2017-03-16 23:53:55 +01:00
|
|
|
choppy = 2,
|
|
|
|
carpet = 1,
|
2016-11-05 07:17:08 +01:00
|
|
|
}
|
2016-09-04 17:09:25 +02:00
|
|
|
}
|
|
|
|
|
2018-01-17 16:10:51 +01:00
|
|
|
-- Register the carpet and recipe using material
|
|
|
|
-- material - already registered material item the textures and sounds applied from
|
|
|
|
-- def - optional additional - or overriding data passed to minetest.register_node()
|
|
|
|
carpets = {}
|
2016-09-04 17:09:25 +02:00
|
|
|
|
2018-01-17 16:10:51 +01:00
|
|
|
function carpets.register(material, def)
|
2017-03-02 21:18:14 +01:00
|
|
|
local node = table.copy(carpet_proto)
|
|
|
|
if def then
|
|
|
|
for k,v in pairs(def) do
|
2018-01-17 16:10:51 +01:00
|
|
|
node[k] = v
|
2017-03-02 21:18:14 +01:00
|
|
|
end
|
2016-09-04 17:09:25 +02:00
|
|
|
end
|
|
|
|
|
2018-01-17 16:10:51 +01:00
|
|
|
local material_def = minetest.registered_nodes[material]
|
2024-06-30 15:08:57 +02:00
|
|
|
node.description = node.description or material_def.description.." carpet"
|
2018-01-17 16:10:51 +01:00
|
|
|
node.sounds = table.copy(node.sounds or material_def.sounds or default.node_sound_defaults())
|
|
|
|
node.groups = table.copy(node.groups)
|
2016-09-04 17:09:25 +02:00
|
|
|
|
2018-01-17 16:10:51 +01:00
|
|
|
if node.tiles then
|
|
|
|
node.tiles = table.copy(node.tiles)
|
|
|
|
elseif material_def.tiles[6] then
|
|
|
|
node.tiles = {material_def.tiles[6]}
|
|
|
|
else
|
|
|
|
node.tiles = table.copy(material_def.tiles)
|
2016-09-04 17:09:25 +02:00
|
|
|
end
|
|
|
|
|
2018-01-17 16:10:51 +01:00
|
|
|
local name = "carpet:" .. (node.name or material:gsub(":", "_"))
|
2016-09-04 17:09:25 +02:00
|
|
|
node.name = nil
|
|
|
|
|
2016-11-05 07:17:08 +01:00
|
|
|
minetest.register_node(":" .. name, node)
|
2016-09-04 17:09:25 +02:00
|
|
|
|
|
|
|
minetest.register_craft({
|
2016-11-05 07:17:08 +01:00
|
|
|
output = name .. " 32",
|
|
|
|
recipe = {
|
|
|
|
{"group:wool", "group:wool", "group:wool"},
|
2018-01-17 16:10:51 +01:00
|
|
|
{"group:wool", material, "group:wool"}
|
2016-11-05 07:17:08 +01:00
|
|
|
}
|
2016-09-04 17:09:25 +02:00
|
|
|
})
|
|
|
|
end
|