-
Notifications
You must be signed in to change notification settings - Fork 4
/
api.lua
56 lines (49 loc) · 1.39 KB
/
api.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
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}
},
groups = {
snappy = 2,
flammable = 3,
oddly_breakable_by_hand = 3,
choppy = 2,
carpet = 1,
}
}
-- 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 = {}
function carpets.register(material, def)
local node = table.copy(carpet_proto)
if def then
for k,v in pairs(def) do
node[k] = v
end
end
local material_def = minetest.registered_nodes[material]
node.description = node.description or material_def.description.." carpet"
node.sounds = table.copy(node.sounds or material_def.sounds or default.node_sound_defaults())
node.groups = table.copy(node.groups)
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)
end
local name = "carpet:" .. (node.name or material:gsub(":", "_"))
node.name = nil
minetest.register_node(":" .. name, node)
minetest.register_craft({
output = name .. " 32",
recipe = {
{"group:wool", "group:wool", "group:wool"},
{"group:wool", material, "group:wool"}
}
})
end