-
Notifications
You must be signed in to change notification settings - Fork 13
/
outside.lua
339 lines (314 loc) · 10.2 KB
/
outside.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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
function ma_pops_furniture.register_hedge(name, def)
-- register nodes
if minetest.get_modpath("default") then
def.sounds = def.sounds or default.node_sound_leaves_defaults()
end
minetest.register_node(name, {
description = def.description or "Hedge",
drawtype = "nodebox",
paramtype = "light",
tiles = {def.texture},
groups = def.groups or
{snappy = 3, flammable = 2, leaves = 1, hedge = 1},
waving = 1,
node_box = {
type = "connected",
fixed = {{-5/16, -0.5, -5/16, 5/16, 5/16, 5/16}},
connect_left = {{-0.5, -0.5, -5/16, -5/16, 5/16, 5/16}},
connect_right = {{5/16, -0.5, -5/16, 0.5, 5/16, 5/16}},
connect_front = {{-5/16, -0.5, -0.5, 5/16, 5/16, -5/16}},
connect_back = {{-5/16, -0.5, 5/16, 5/16, 5/16, 0.5}},
},
connects_to = {"group:fence", "group:wood", "group:tree", "group:hedge"},
light_source = def.light_source or 0,
sounds = def.sounds,
after_place_node = function(pos, placer, itemstack, pointed_thing)
local pos_under = {x = pos.x, y = pos.y - 1, z = pos.z}
local pos_above = {x = pos.x, y = pos.y + 1, z = pos.z}
local node_under = string.gsub(minetest.get_node(pos_under).name, "_full$", "")
local node_above = string.gsub(minetest.get_node(pos_above).name, "_full$", "")
if minetest.get_item_group(node_under, "hedge") == 1 then
minetest.set_node(pos_under, {name = node_under .. "_full"})
end
if minetest.get_item_group(node_above, "hedge") == 1 then
minetest.set_node(pos, {name = name .. "_full"})
end
end,
after_dig_node = function(pos, oldnode, oldmetadata, digger)
local pos_under = {x = pos.x, y = pos.y - 1, z = pos.z}
local node_under = string.gsub(minetest.get_node(pos_under).name, "_full$", "")
if minetest.get_item_group(node_under, "hedge") == 1 and
digger and digger:is_player() then
minetest.set_node(pos_under, {name = node_under})
end
end,
})
minetest.register_node(name .. "_full", {
description = def.description or "Hedge",
drawtype = "nodebox",
paramtype = "light",
tiles = {def.texture},
groups = def.groups or
{snappy = 3, flammable = 2, leaves = 1, hedge = 1,
not_in_creative_inventory = 1},
waving = 1,
node_box = {
type = "connected",
fixed = {{-5/16, -0.5, -5/16, 5/16, 0.5, 5/16}},
connect_left = {{-0.5, -0.5, -5/16, -5/16, 0.5, 5/16}},
connect_right = {{5/16, -0.5, -5/16, 0.5, 0.5, 5/16}},
connect_front = {{-5/16, -0.5, -0.5, 5/16, 0.5, -5/16}},
connect_back = {{-5/16, -0.5, 5/16, 5/16, 0.5, 0.5}},
},
connects_to = {"group:fence", "group:wood", "group:tree", "group:hedge"},
light_source = def.light_source or 0,
sounds = def.sounds,
drop = name,
after_dig_node = function(pos, oldnode, oldmetadata, digger)
local pos_under = {x = pos.x, y = pos.y - 1, z = pos.z}
local node_under = string.gsub(minetest.get_node(pos_under).name, "_full$", "")
if minetest.get_item_group(node_under, "hedge") == 1 and
digger and digger:is_player() then
minetest.set_node(pos_under, {name = node_under})
end
end,
})
-- register crafting recipe
minetest.register_craft({
output = name .. " 4",
recipe = {
{def.material, def.material, def.material},
{def.material, def.material, def.material},
}
})
end
-- register hedges if default mod found
if minetest.get_modpath("default") then
ma_pops_furniture.register_hedge("ma_pops_furniture:apple_hedge", {
description = "Apple Hedge",
texture = "default_leaves.png",
material = "default:leaves",
})
ma_pops_furniture.register_hedge("ma_pops_furniture:jungle_hedge", {
description = "Jungle Hedge",
texture = "default_jungleleaves.png",
material = "default:jungleleaves",
})
ma_pops_furniture.register_hedge("ma_pops_furniture:pine_hedge", {
description = "Pine Hedge",
texture = "default_pine_needles.png",
material = "default:pine_needles",
})
ma_pops_furniture.register_hedge("ma_pops_furniture:acacia_hedge", {
description = "Acacia Hedge",
texture = "default_acacia_leaves.png",
material = "default:acacia_leaves",
})
ma_pops_furniture.register_hedge("ma_pops_furniture:aspen_hedge", {
description = "Aspen Hedge",
texture = "default_aspen_leaves.png",
material = "default:aspen_leaves",
})
end
-- alternative recipes using bush leaves
minetest.register_craft({
output = "hedges:apple_hedge 4",
recipe = {
{"default:bush_leaves", "default:bush_leaves", "default:bush_leaves"},
{"default:bush_leaves", "default:bush_leaves", "default:bush_leaves"},
}
})
minetest.register_craft({
output = "hedges:acacia_hedge 4",
recipe = {
{"default:acacia_bush_leaves", "default:acacia_bush_leaves", "default:acacia_bush_leaves"},
{"default:acacia_bush_leaves", "default:acacia_bush_leaves", "default:acacia_bush_leaves"},
}
})
minetest.register_node('ma_pops_furniture:birdbath', {
description = 'Birdbath',
drawtype = 'mesh',
mesh = 'FM_birdbath.obj',
tiles = {{name='default_stone.png'},{name='default_water_source_animated.png', animation={type='vertical_frames', aspect_w=16, aspect_h=16, length=2.0}}},
groups = {cracky=2, oddly_breakable_by_hand=5, furniture=1},
paramtype = 'light',
paramtype2 = 'facedir',
sounds = moditems.STONE_SOUNDS,
})
minetest.register_node('ma_pops_furniture:doorbell', {
description = 'Doorbell',
drawtype = 'nodebox',
tiles = {
"mp_db_top.png",
"mp_db_top.png",
"mp_db_right.png",
"mp_db_left.png",
"default_wood.png",
"mp_db_front.png"
},
groups = {cracky=2, oddly_breakable_by_hand=5, furniture=1},
paramtype = 'light',
paramtype2 = 'facedir',
sounds = moditems.STONE_SOUNDS,
on_rightclick = function(pos, node, clicker, itemstack)
node.name = "ma_pops_furniture:doorbell_ring"
minetest.swap_node(pos, node)
-- one second ring.
minetest.get_node_timer(pos):start(1.0)
end,
sounds = moditems.STONE_SOUNDS,
node_box = {
type = "fixed",
fixed = {
{-0.125, -0.375, 0.4375, 0.125, -0.125, 0.5},
{-0.0625, -0.3125, 0.375, 0.0625, -0.1875, 0.4375},
},
}
})
minetest.register_node('ma_pops_furniture:doorbell_ring', {
description = 'Doorbell (ring)',
drawtype = 'nodebox',
tiles = {
"mp_db_top.png",
"mp_db_top.png",
"mp_db_right.png",
"mp_db_left.png",
"default_wood.png",
"mp_db_front.png"
},
groups = {cracky=2, oddly_breakable_by_hand=5, furniture=1, not_in_creative_inventory=1},
drop = 'ma_pops_furniture:doorbell',
on_timer = function(pos,elapsed)
local node = minetest.get_node(pos)
node.name = "ma_pops_furniture:doorbell"
minetest.swap_node(pos, node)
end,
paramtype = 'light',
paramtype2 = 'facedir',
sounds = moditems.STONE_SOUNDS,
node_box = {
type = "fixed",
fixed = {
{-0.125, -0.375, 0.4375, 0.125, -0.125, 0.5},
{-0.0625, -0.3125, 0.375, 0.0625, -0.1875, 0.4375},
},
}
})
minetest.register_node('ma_pops_furniture:stone_path_1', {
description = 'Stone Path',
drawtype = 'mesh',
mesh = 'FM_stone_path_1.obj',
tiles = {'default_stone.png'},
groups = {cracky=2, oddly_breakable_by_hand=5, furniture=1},
paramtype = 'light',
paramtype2 = 'facedir',
sounds = moditems.STONE_SOUNDS,
selection_box = {
type = 'fixed',
fixed = {-.5, -.5, -.5, .5, -.4, .5},
},
collision_box = {
type = 'fixed',
fixed = {-.5, -.5, -.5, .5, -.4, .5},
},
on_place = function(itemstack, placer, pointed_thing)
local stack = ItemStack("ma_pops_furniture:stone_path_" .. math.random(1,4))
local ret = minetest.item_place(stack, placer, pointed_thing)
return ItemStack("ma_pops_furniture:stone_path_1 " ..
itemstack:get_count() - (1 - ret:get_count()))
end,
})
for i = 2, 4 do
minetest.register_node('ma_pops_furniture:stone_path_'..i, {
description = 'Stone Path',
drawtype = 'mesh',
mesh = 'FM_stone_path_'..i..'.obj',
tiles = {'default_stone.png'},
groups = {cracky=2, oddly_breakable_by_hand=5, furniture=1, not_in_creative_inventory=1},
paramtype = 'light',
paramtype2 = 'facedir',
sounds = moditems.STONE_SOUNDS,
drop = 'ma_pops_furniture:stone_path_1',
selection_box = {
type = 'fixed',
fixed = {-.5, -.5, -.5, .5, -.4, .5},
},
collision_box = {
type = 'fixed',
fixed = {-.5, -.5, -.5, .5, -.4, .5},
},
})
end
minetest.register_node("ma_pops_furniture:outdoor_lamp", {
description = "Outdoor Lamp",
tiles = {
"default_stone.png",
"default_stone.png^mp_light_off.png",
"default_stone.png",
"default_stone.png",
"default_stone.png",
"default_stone.png"
},
drawtype = "nodebox",
paramtype = "light",
paramtype2 = "facedir",
sounds = moditems.STONE_SOUNDS,
on_rightclick = function (pos, node, player, itemstack, pointed_thing)
node.name = "ma_pops_furniture:outdoor_lamp_on"
minetest.set_node(pos, node)
end,
groups = {choppy = 2, oddly_breakable_by_hand = 2},
node_box = {
type = "fixed",
fixed = {
{-0.125, 0.25, -0.125, 0.125, 0.5, 0.125},
},
}
})
minetest.register_node("ma_pops_furniture:outdoor_lamp_on", {
description = "Outdoor Lamp On",
tiles = {
"default_stone.png",
"default_stone.png^mp_light_on.png",
"default_stone.png",
"default_stone.png",
"default_stone.png",
"default_stone.png"
},
drawtype = "nodebox",
paramtype = "light",
paramtype2 = "facedir",
light_source = 14,
drop = 'ma_pops_furniture:outdoor_lamp',
sounds = moditems.STONE_SOUNDS,
on_rightclick = function (pos, node, player, itemstack, pointed_thing)
node.name = "ma_pops_furniture:outdoor_lamp"
minetest.set_node(pos, node)
end,
groups = {choppy = 2, oddly_breakable_by_hand = 2, not_in_creative_inventory = 1},
node_box = {
type = "fixed",
fixed = {
{-0.125, 0.25, -0.125, 0.125, 0.5, 0.125},
},
}
})
minetest.register_node("ma_pops_furniture:trampoline", {
description = "Trampoline",
tiles = {"mp_trampoline_top.png", "default_coal_block.png", "mp_trampoline_side.png"},
drawtype="nodebox",
paramtype2="facedir",
paramtype="light",
groups = {cracky=3, oddly_breakable_by_hand=1, fall_damage_add_percent=-80, bouncy=90},
sounds = {wood = {name="xdecor_bouncy", gain=0.8}},
node_box = {
type = "fixed",
fixed = {
{-0.5, -0.3125, -0.5, 0.5, 0, 0.5}, -- NodeBox1
{0.1875, -0.5, 0.1875, 0.5, -0.3125, 0.5}, -- NodeBox2
{-0.5, -0.5, 0.1875, -0.1875, -0.3125, 0.5}, -- NodeBox3
{-0.5, -0.5, -0.5, -0.1875, -0.3125, -0.1875}, -- NodeBox4
{0.1875, -0.5, -0.5, 0.5, -0.3125, -0.1875}, -- NodeBox5
},
}
})