-
Notifications
You must be signed in to change notification settings - Fork 6
/
init.lua
136 lines (125 loc) · 4 KB
/
init.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
compost = {}
compost.items = {}
function compost.register_item(name)
compost.items[name] = true
end
compost.register_item("default:grass_1")
compost.register_item("default:junglegrass")
compost.register_item("default:leaves")
compost.register_item("default:jungleleaves")
compost.register_item("default:pine_needles")
compost.register_item("default:dirt")
compost.register_item("default:dirt_with_grass")
compost.register_item("default:stick")
compost.register_item("flowers:geranium")
compost.register_item("flowers:tulip")
compost.register_item("flowers:rose")
minetest.register_node("compost:wood_barrel", {
description = "Wood Barrel",
tiles = {"default_wood.png"},
drawtype = "nodebox",
node_box = {
type = "fixed",
fixed = {{-1/2, -1/2, -1/2, 1/2, -3/8, 1/2},
{-1/2, -1/2, -1/2, -3/8, 1/2, 1/2},
{3/8, -1/2, -1/2, 1/2, 1/2, 1/2},
{-1/2, -1/2, -1/2, 1/2, 1/2, -3/8},
{-1/2, -1/2, 3/8, 1/2, 1/2, 1/2}},
},
paramtype = "light",
is_ground_content = false,
groups = {choppy = 3},
sounds = default.node_sound_wood_defaults(),
on_punch = function(pos, node, puncher, pointed_thing)
local wielded_item = puncher:get_wielded_item():get_name()
if compost.items[wielded_item] then
minetest.set_node(pos, {name = "compost:wood_barrel_1"})
local w = puncher:get_wielded_item()
w:take_item(1)
puncher:set_wielded_item(w)
end
end
})
minetest.register_node("compost:wood_barrel_1", {
description = "Wood Barrel with compost",
tiles = {"default_wood.png^compost_compost_1.png", "default_wood.png"},
drawtype = "nodebox",
node_box = {
type = "fixed",
fixed = {{-1/2, -1/2, -1/2, 1/2, -3/8, 1/2},
{-1/2, -1/2, -1/2, -3/8, 1/2, 1/2},
{3/8, -1/2, -1/2, 1/2, 1/2, 1/2},
{-1/2, -1/2, -1/2, 1/2, 1/2, -3/8},
{-1/2, -1/2, 3/8, 1/2, 1/2, 1/2},
{-3/8, -1/2, -3/8, 3/8, 3/8, 3/8}},
},
paramtype = "light",
is_ground_content = false,
groups = {choppy = 3},
sounds = default.node_sound_wood_defaults(),
})
minetest.register_node("compost:wood_barrel_2", {
description = "Wood Barrel with compost",
tiles = {"default_wood.png^compost_compost_2.png", "default_wood.png"},
drawtype = "nodebox",
node_box = {
type = "fixed",
fixed = {{-1/2, -1/2, -1/2, 1/2, -3/8, 1/2},
{-1/2, -1/2, -1/2, -3/8, 1/2, 1/2},
{3/8, -1/2, -1/2, 1/2, 1/2, 1/2},
{-1/2, -1/2, -1/2, 1/2, 1/2, -3/8},
{-1/2, -1/2, 3/8, 1/2, 1/2, 1/2},
{-3/8, -1/2, -3/8, 3/8, 3/8, 3/8}},
},
paramtype = "light",
is_ground_content = false,
groups = {choppy = 3},
sounds = default.node_sound_wood_defaults(),
})
minetest.register_node("compost:wood_barrel_3", {
description = "Wood Barrel",
tiles = {"default_wood.png^compost_compost_3.png", "default_wood.png"},
drawtype = "nodebox",
node_box = {
type = "fixed",
fixed = {{-1/2, -1/2, -1/2, 1/2, -3/8, 1/2},
{-1/2, -1/2, -1/2, -3/8, 1/2, 1/2},
{3/8, -1/2, -1/2, 1/2, 1/2, 1/2},
{-1/2, -1/2, -1/2, 1/2, 1/2, -3/8},
{-1/2, -1/2, 3/8, 1/2, 1/2, 1/2},
{-3/8, -1/2, -3/8, 3/8, 3/8, 3/8}},
},
paramtype = "light",
is_ground_content = false,
groups = {choppy = 3},
sounds = default.node_sound_wood_defaults(),
on_punch = function(pos, node, player, pointed_thing)
local p = {x = pos.x + math.random(0, 5)/5 - 0.5, y = pos.y+1, z = pos.z + math.random(0, 5)/5 - 0.5}
minetest.add_item(p, {name = "default:dirt"})
minetest.set_node(pos, {name = "compost:wood_barrel"})
end
})
minetest.register_abm({
nodenames = {"compost:wood_barrel_1"},
interval = 5.0,
chance = 3,
action = function(pos, node, active_object_count, active_object_count_wider)
minetest.set_node(pos, {name = "compost:wood_barrel_2"})
end,
})
minetest.register_abm({
nodenames = {"compost:wood_barrel_2"},
interval = 5.0,
chance = 3,
action = function(pos, node, active_object_count, active_object_count_wider)
minetest.set_node(pos, {name = "compost:wood_barrel_3"})
end,
})
minetest.register_craft({
output = "compost:wood_barrel",
recipe = {
{"default:wood", "", "default:wood"},
{"default:wood", "", "default:wood"},
{"default:wood", "stairs:slab_wood", "default:wood"}
}
})