-
Notifications
You must be signed in to change notification settings - Fork 5
/
nodes.lua
582 lines (527 loc) · 17.9 KB
/
nodes.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
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
-- clone node from VanessaE's moretrees
-- https://github.com/VanessaE/moretrees
function vmg.clone_node(name)
local node2 = {}
local node = minetest.registered_nodes[name]
for k,v in pairs(node) do
node2[k]=v
end
return node2
end
-- Set the liquid range according to settings (by default 3)
local waterflow = vmg.define("waterflow", 3)
minetest.override_item("default:river_water_source", {liquid_range = waterflow})
minetest.override_item("default:river_water_flowing", {liquid_range = waterflow})
-- Add silt
minetest.register_node("valleys_mapgen:silt", {
description = "Silt",
tiles = {"vmg_silt.png"},
is_ground_content = true,
groups = {crumbly=3},
sounds = default.node_sound_dirt_defaults(),
})
-- I don't like the default:clay, this does not look like clay. So add red clay.
minetest.register_node("valleys_mapgen:red_clay", {
description = "Red Clay",
tiles = {"vmg_red_clay.png"},
is_ground_content = true,
groups = {crumbly=3},
sounds = default.node_sound_dirt_defaults(),
})
minetest.override_item("default:clay", {description = "White Clay"})
-- Add dirts
local function register_dirts(readname)
local name = readname:lower()
local itemstr_dirt = "valleys_mapgen:dirt_" .. name
local itemstr_lawn = itemstr_dirt .. "_with_grass"
local itemstr_dry = itemstr_dirt .. "_with_dry_grass"
local itemstr_snow = itemstr_dirt .. "_with_snow"
local tilestr = "vmg_dirt_" .. name .. ".png"
minetest.register_node(itemstr_dirt, {
description = readname .. " Dirt",
tiles = {tilestr},
is_ground_content = true,
groups = {crumbly=3,soil=1},
sounds = default.node_sound_dirt_defaults(),
})
minetest.register_node(itemstr_lawn, {
description = readname .. " Dirt with Grass",
tiles = {"default_grass.png", tilestr, tilestr .. "^default_grass_side.png"},
is_ground_content = true,
groups = {crumbly=3,soil=1},
drop = itemstr_dirt,
sounds = default.node_sound_dirt_defaults({
footstep = {name="default_grass_footstep", gain=0.25},
}),
})
minetest.register_node(itemstr_dry, {
description = readname .. " Dirt with Dry Grass",
tiles = {"default_dry_grass.png", tilestr, tilestr .. "^default_dry_grass_side.png"},
groups = {crumbly=3, soil=1},
drop = itemstr_dirt,
sounds = default.node_sound_dirt_defaults({
footstep = {name = "default_grass_footstep", gain=0.4},
}),
})
minetest.register_node(itemstr_snow, {
description = readname .. " Dirt with Snow",
tiles = {"default_snow.png", tilestr, tilestr .. "^default_snow_side.png"},
is_ground_content = true,
groups = {crumbly=3,soil=1},
drop = itemstr_dirt,
sounds = default.node_sound_dirt_defaults({
footstep = {name="default_snow_footstep", gain=0.25},
}),
})
minetest.register_abm({
nodenames = {itemstr_dirt},
interval = 2,
chance = 200,
action = function(pos, node)
local above = {x=pos.x, y=pos.y+1, z=pos.z}
local name = minetest.get_node(above).name
local nodedef = minetest.registered_nodes[name]
if nodedef and (nodedef.sunlight_propagates or nodedef.paramtype == "light")
and nodedef.liquidtype == "none"
and (minetest.get_node_light(above) or 0) >= 13 then
if name == "default:snow" or name == "default:snowblock" or (vmg.test_snow and vmg.test_snow({x=pos.x, y=pos.y+1, z=pos.z})) then
minetest.set_node(pos, {name = itemstr_snow})
elseif vmg.test_dry and vmg.test_dry(pos) then
minetest.set_node(pos, {name = itemstr_dry})
else
minetest.set_node(pos, {name = itemstr_lawn})
end
end
end
})
minetest.register_abm({
nodenames = {itemstr_lawn, itemstr_dry},
interval = 2,
chance = 20,
action = function(pos, node)
local above = {x=pos.x, y=pos.y+1, z=pos.z}
local name = minetest.get_node(above).name
local nodedef = minetest.registered_nodes[name]
if name ~= "ignore" and nodedef
and not ((nodedef.sunlight_propagates or nodedef.paramtype == "light")
and nodedef.liquidtype == "none") then
minetest.set_node(pos, {name = itemstr_dirt})
end
end
})
end
-- 3 types of dirt :
-- Clayey dirt is a dirt that contains clay, but is not pure clay
register_dirts("Clayey")
-- Idem for silty dirt that contains silt without beeing pure silt
register_dirts("Silty")
-- And sandy dirt
register_dirts("Sandy")
-----------
-- Trees --
-----------
-- Credits / Notes
-- Banana tree: textures by demon_boy
-- Birch tree: textures from Forest mod by Gael-de-Sailly
-- Cherry Blossom tree: textures by demon_boy
-- Mangrove tree: textures by demon_boy
-- Fir tree: Fir trees don't exist in the default game. Textures from Forest mod by Gael-de-Sailly
-- Willow tree: textures from Forest mod by Gael-de-Sailly
-- a list of tree descriptions
vmg.treelist = {
{name="banana",
desc="Banana",
leaf="leaves",
leaf_desc="Leaves",
leaf_tile="banana_leaves",
fruit="banana",
fruit_desc="Banana",
drop_rarity=20,
selbox={-0.35, -0.5, -0.35, 0.35, 0.5, 0.35},
health=3,
trunk_dia=0.75},
{name="birch",
desc="Birch",
leaf="leaves",
leaf_desc="Leaves",
leaf_tile="birch_leaves",
drop_rarity=20,
trunk_dia=0.5},
{name="cherry_blossom",
desc="Cherry Blossom",
leaf="leaves",
leaf_desc="Leaves",
leaf_tile="cherry_blossom_leaves",
drop_rarity=20,
trunk_dia=0.5},
{name="fir",
desc="Fir",
leaf="needles",
leaf_desc="Needles",
leaf_tile="fir_leaves",
drop_rarity=20,
trunk_dia=1.0},
{name="mangrove",
desc="Mangrove",
leaf="leaves",
leaf_desc="Leaves",
leaf_tile="mangrove_leaves",
drop_rarity=20,
trunk_dia=0.5},
{name="willow",
desc="Willow",
leaf="leaves",
leaf_desc="Leaves",
leaf_tile="willow_leaves",
drop_rarity=20,
trunk_dia=1.0},
}
for _, tree in ipairs(vmg.treelist) do
-- a standard node description
local node_d = {
description = tree.desc.." Tree",
tiles = {
"vmg_"..tree.name.."_tree_top.png",
"vmg_"..tree.name.."_tree_top.png",
"vmg_"..tree.name.."_tree.png"
},
paramtype2 = "facedir",
is_ground_content = true,
groups = {tree=1,choppy=2,oddly_breakable_by_hand=1,flammable=2},
sounds = default.node_sound_wood_defaults(),
on_place = minetest.rotate_node,
}
-- Some trunks aren't a meter wide.
if tree.trunk_dia and tree.trunk_dia ~= 1 then
local radius = tree.trunk_dia / 2
node_d.paramtype = "light"
node_d.drawtype = "nodebox"
node_d.node_box = { type = "fixed",
fixed = { {-radius, -0.5, -radius, radius, 0.5, radius}, }
}
end
minetest.register_node("valleys_mapgen:"..tree.name.."_tree", node_d)
-- planks that come from the tree
minetest.register_node("valleys_mapgen:"..tree.name.."_wood", {
description = tree.desc.." Planks",
tiles = {"vmg_"..tree.name.."_wood.png"},
is_ground_content = true,
groups = {choppy=2,oddly_breakable_by_hand=2,flammable=3,wood=1},
sounds = default.node_sound_wood_defaults(),
})
-- how to get the planks
minetest.register_craft({
output = "valleys_mapgen:"..tree.name.."_wood 5",
recipe = {
{"valleys_mapgen:"..tree.name.."_tree"}
}
})
-- the tree's sapling form
minetest.register_node("valleys_mapgen:"..tree.name.."_sapling", {
description = tree.desc.." Sapling",
drawtype = "plantlike",
visual_scale = 1.0,
tiles = {"vmg_"..tree.name.."_sapling.png"},
inventory_image = "vmg_"..tree.name.."_sapling.png",
wield_image = "vmg_"..tree.name.."_sapling.png",
paramtype = "light",
sunlight_propagates = true,
walkable = false,
selection_box = {
type = "fixed",
fixed = {-0.3, -0.5, -0.3, 0.3, 0.35, 0.3}
},
groups = {snappy=2,dig_immediate=3,flammable=2,attached_node=1,sapling=1},
sounds = default.node_sound_leaves_defaults(),
})
-- leaves for the tree
minetest.register_node("valleys_mapgen:"..tree.name.."_"..tree.leaf.."", {
description = tree.desc.." "..tree.leaf_desc.."",
drawtype = "allfaces_optional",
waving = 1,
visual_scale = 1.3,
tiles = { "vmg_"..tree.leaf_tile..".png"},
paramtype = "light",
is_ground_content = false,
groups = {snappy=3, leafdecay=7, flammable=2, leaves=1},
drop = {
max_items = 1,
items = {
{items = {"valleys_mapgen:"..tree.name.."_sapling"}, rarity = tree.drop_rarity },
{items = {"valleys_mapgen:"..tree.name.."_"..tree.leaf..""} }
}
},
sounds = default.node_sound_leaves_defaults(),
after_place_node = default.after_place_leaves,
})
-- appropriate fruit
if tree.fruit then
minetest.register_node("valleys_mapgen:"..tree.fruit.."", {
description = tree.fruit_desc,
drawtype = "plantlike",
visual_scale = 1.0,
tiles = { "vmg_"..tree.fruit..".png" },
inventory_image = "vmg_"..tree.fruit..".png",
wield_image = "vmg_"..tree.fruit..".png",
paramtype = "light",
sunlight_propagates = true,
walkable = false,
is_ground_content = false,
selection_box = {
type = "fixed",
fixed = tree.selbox
},
groups = {fleshy=3,dig_immediate=3,flammable=2, leafdecay=3,leafdecay_drop=1},
-- Fruit makes you healthy.
on_use = minetest.item_eat(tree.health),
sounds = default.node_sound_leaves_defaults(),
after_place_node = function(pos, placer, itemstack)
if placer:is_player() then
minetest.set_node(pos, {name="valleys_mapgen:"..tree.fruit.."", param2=1})
end
end,
})
end
-- appropriate wooden stairs and slabs
if minetest.get_modpath("stairs") then
stairs.register_stair_and_slab(
"vmg_"..tree.name.."_tree",
"valleys_mapgen:"..tree.name.."_tree",
{snappy=1, choppy=2, oddly_breakable_by_hand=1, flammable=2 },
{ "vmg_"..tree.name.."_tree_top.png",
"vmg_"..tree.name.."_tree_top.png",
"vmg_"..tree.name.."_tree.png"
},
tree.desc.." Tree Stair",
tree.desc.." Tree Slab",
default.node_sound_wood_defaults()
)
stairs.register_stair_and_slab(
"vmg_"..tree.name.."_wood",
"valleys_mapgen:"..tree.name.."_wood",
{ snappy=1, choppy=2, oddly_breakable_by_hand=2, flammable=3 },
{"vmg_"..tree.name.."_wood.png" },
tree.desc.." Planks Stair",
tree.desc.." Planks Slab",
default.node_sound_wood_defaults()
)
end
end
----------------------
-- Flowers / Plants --
----------------------
-- Credits / Notes
-- Arrow Arum: texture by demon_boy
-- Bird of Paradise: texture by demon_boy
-- Calla Lily: texture by demon_boy
-- Gerbera: texture by demon_boy
-- Hibiscus: texture by demon_boy
-- Mangrove Fern: texture by demon_boy
-- Orchid: texture by demon_boy
vmg.plantlist = {
-- plantname plantdesc plantwave plantlight plantgroup selbox
{"arrow_arum", "Arrow Arum", 1, "false", "plantnodye", {-0.5, -0.5, -0.5, 0.5, -0.3125, 0.5}},
{"bird_of_paradise", "Bird of Paradise", 0, "true", "flowernodye", {-0.5, -0.5, -0.5, 0.5, -0.3125, 0.5}},
{"calla_lily", "Calla Lily", 1, "true", "flowerwhitedye", {-0.5, -0.5, -0.5, 0.5, -0.3125, 0.5}},
{"gerbera", "Gerbera", 0, "true", "flowerpinkdye", {-0.15, -0.5, -0.15, 0.15, 0.2, 0.15}},
{"hibiscus", "Hibiscus", 1, "false", "flowerwhitedye", {-0.5, -0.5, -0.5, 0.5, -0.3125, 0.5}},
{"mangrove_fern", "Mangrove Fern", 1, "false", "flowernodye", {-0.5, -0.5, -0.5, 0.5, -0.3125, 0.5}},
{"orchid", "Orchid", 1, "true", "flowerwhitedye", {-0.5, -0.5, -0.5, 0.5, -0.3125, 0.5}},
}
for i in ipairs(vmg.plantlist) do
local plantname = vmg.plantlist[i][1]
local plantdesc = vmg.plantlist[i][2]
local plantwave = vmg.plantlist[i][3]
local plantlight = vmg.plantlist[i][4]
local plantgroup = vmg.plantlist[i][5]
local selbox = vmg.plantlist[i][6]
--group definitions
if vmg.plantlist[i][5] == "plantnodye" then
plantgroups = {snappy=3,flammable=2,flora=1,attached_node=1}
elseif vmg.plantlist[i][5] == "flowernodye" then
plantgroups = {snappy=3,flammable=2,flower=1,flora=1,attached_node=1}
elseif vmg.plantlist[i][5] == "flowerpinkdye" then
plantgroups = {snappy=3,flammable=2,flower=1,flora=1,attached_node=1,color_pink=1}
elseif vmg.plantlist[i][5] == "flowerwhitedye" then
plantgroups = {snappy=3,flammable=2,flower=1,flora=1,attached_node=1,color_white=1}
end
minetest.register_node("valleys_mapgen:"..plantname.."", {
description = plantdesc,
drawtype = "plantlike",
tiles = {"vmg_"..plantname..".png"},
inventory_image = "vmg_"..plantname..".png",
waving = plantwave,
sunlight_propagates = plantlight,
paramtype = "light",
walkable = false,
groups = plantgroups,
sounds = default.node_sound_leaves_defaults(),
selection_box = {
type = "fixed",
fixed = selbox,
},
})
end
minetest.register_node("valleys_mapgen:mangrove_roots", {
description = "Mangrove Roots",
drawtype = "plantlike",
tiles = {"vmg_mangrove_roots.png"},
paramtype = "light",
is_ground_content = true,
groups = {snappy=1,choppy=2,oddly_breakable_by_hand=1,flammable=2},
sounds = default.node_sound_wood_defaults(),
})
minetest.register_node("valleys_mapgen:huge_mushroom_cap", {
description = "Huge Mushroom Cap",
tiles = {"vmg_mushroom_giant_cap.png", "vmg_mushroom_giant_under.png", "vmg_mushroom_giant_cap.png"},
is_ground_content = false,
paramtype = "light",
drawtype = "nodebox",
node_box = { type = "fixed",
fixed = {
{-0.5, -0.5, -0.33, 0.5, -0.33, 0.33},
{-0.33, -0.5, 0.33, 0.33, -0.33, 0.5},
{-0.33, -0.5, -0.33, 0.33, -0.33, -0.5},
{-0.33, -0.33, -0.33, 0.33, -0.17, 0.33},
} },
light_source = 4,
groups = {oddly_breakable_by_hand=1, dig_immediate=3, flammable=2, plant=1, leafdecay=1},
})
minetest.register_node("valleys_mapgen:giant_mushroom_cap", {
description = "Giant Mushroom Cap",
tiles = {"vmg_mushroom_giant_cap.png", "vmg_mushroom_giant_under.png", "vmg_mushroom_giant_cap.png"},
is_ground_content = false,
paramtype = "light",
drawtype = "nodebox",
node_box = { type = "fixed",
fixed = {
{-0.4, -0.5, -0.4, 0.4, 0.0, 0.4},
{-0.75, -0.5, -0.4, -0.4, -0.25, 0.4},
{0.4, -0.5, -0.4, 0.75, -0.25, 0.4},
{-0.4, -0.5, -0.75, 0.4, -0.25, -0.4},
{-0.4, -0.5, 0.4, 0.4, -0.25, 0.75},
} },
light_source = 8,
groups = {oddly_breakable_by_hand=1, dig_immediate=3, flammable=2, plant=1, leafdecay=1},
})
minetest.register_node("valleys_mapgen:giant_mushroom_stem", {
description = "Giant Mushroom Stem",
tiles = {"vmg_mushroom_giant_under.png", "vmg_mushroom_giant_under.png", "vmg_mushroom_giant_stem.png"},
is_ground_content = false,
groups = {tree=1,choppy=2,oddly_breakable_by_hand=1,flammable=2, plant=1},
sounds = default.node_sound_wood_defaults(),
paramtype = "light",
drawtype = "nodebox",
node_box = { type = "fixed", fixed = { {-0.25, -0.5, -0.25, 0.25, 0.5, 0.25}, }},
})
minetest.register_craft({
output = "default:wood",
recipe = {
{"valleys_mapgen:giant_mushroom_stem"}
}
})
minetest.register_craftitem("valleys_mapgen:mushroom_steak", {
description = "Mushroom Steak",
inventory_image = "vmg_mushroom_steak.png",
on_use = minetest.item_eat(4),
})
minetest.register_craft({
type = "cooking",
output = "valleys_mapgen:mushroom_steak",
recipe = "valleys_mapgen:huge_mushroom_cap",
cooktime = 2,
})
minetest.register_craft({
type = "cooking",
output = "valleys_mapgen:mushroom_steak 2",
recipe = "valleys_mapgen:giant_mushroom_cap",
cooktime = 2,
})
minetest.register_node("valleys_mapgen:glowing_fungal_stone", {
description = "Glowing Fungal Stone",
tiles = {"default_stone.png^vmg_glowing_fungal.png",},
is_ground_content = true,
light_source = 8,
groups = {cracky=3, stone=1},
drop = {items={ {items={"default:cobble"},}, {items={"valleys_mapgen:glowing_fungus",},},},},
sounds = default.node_sound_stone_defaults(),
})
minetest.register_node("valleys_mapgen:glowing_fungus", {
description = "Glowing Fungus",
inventory_image = "vmg_glowing_fungus.png",
})
minetest.register_node("valleys_mapgen:moon_juice", {
description = "Moon Juice",
inventory_image = "vmg_moon_juice.png",
})
minetest.register_node("valleys_mapgen:moon_glass", {
description = "Moon Glass",
drawtype = "glasslike",
tiles = {"default_glass.png",},
is_ground_content = true,
light_source = 14,
groups = {cracky=3},
sounds = default.node_sound_glass_defaults(),
})
minetest.register_craft({
output = "valleys_mapgen:moon_juice",
recipe = {
{"valleys_mapgen:glowing_fungus", "valleys_mapgen:glowing_fungus", "valleys_mapgen:glowing_fungus"},
{"valleys_mapgen:glowing_fungus", "valleys_mapgen:glowing_fungus", "valleys_mapgen:glowing_fungus"},
{"valleys_mapgen:glowing_fungus", "vessels:glass_bottle", "valleys_mapgen:glowing_fungus"},
},
})
minetest.register_craft({
output = "valleys_mapgen:moon_glass",
recipe = {
{"", "valleys_mapgen:moon_juice", ""},
{"", "valleys_mapgen:moon_juice", ""},
{"", "default:glass", ""},
},
})
minetest.register_node("valleys_mapgen:stalactite", {
description = "Stalactite",
tiles = {"default_stone.png"},
is_ground_content = false,
walkable = false,
paramtype = "light",
drawtype = "nodebox",
node_box = { type = "fixed",
fixed = {
{-0.07, 0.0, -0.07, 0.07, 0.5, 0.07},
{-0.04, -0.25, -0.04, 0.04, 0.0, 0.04},
{-0.02, -0.5, -0.02, 0.02, 0.25, 0.02},
} },
groups = {stone=1, cracky=3},
sounds = default.node_sound_stone_defaults(),
})
minetest.register_node("valleys_mapgen:stalagmite", {
description = "Stalagmite",
tiles = {"default_stone.png"},
is_ground_content = false,
walkable = false,
paramtype = "light",
drawtype = "nodebox",
node_box = { type = "fixed",
fixed = {
{-0.07, -0.5, -0.07, 0.07, 0.0, 0.07},
{-0.04, 0.0, -0.04, 0.04, 0.25, 0.04},
{-0.02, 0.25, -0.02, 0.02, 0.5, 0.02},
} },
groups = {stone=1, cracky=3},
sounds = default.node_sound_stone_defaults(),
})
-- Change leafdecay ratings
minetest.add_group("default:leaves", {leafdecay = 5})
minetest.add_group("default:jungleleaves", {leafdecay = 8})
minetest.add_group("default:pine_needles", {leafdecay = 7})
-- Make some new leaves with the same properties.
local newnode = vmg.clone_node("default:leaves")
newnode.tiles = {"default_leaves.png^[colorize:#FF0000:20"}
minetest.register_node("valleys_mapgen:leaves2", newnode)
newnode.tiles = {"default_leaves.png^[colorize:#FFFF00:20"}
minetest.register_node("valleys_mapgen:leaves3", newnode)
newnode.tiles = {"default_leaves.png^[colorize:#00FFFF:20"}
minetest.register_node("valleys_mapgen:leaves4", newnode)
newnode.tiles = {"default_leaves.png^[colorize:#00FF00:20"}
minetest.register_node("valleys_mapgen:leaves5", newnode)