summaryrefslogtreecommitdiff
path: root/farming/mapgen.lua
blob: 2554a150b28afc726b2aa6a088564a5fc8916ea4 (plain)
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

-- decoration function
local function register_plant(name, min, max, spawnon, spawnby, num, enabled)

	if enabled ~= true then
		return
	end

	minetest.register_decoration({
		deco_type = "simple",
		place_on = spawnon or {"default:dirt_with_grass"},
		sidelen = 16,
		noise_params = {
			offset = 0,
			scale = farming.rarety, -- 0.006,
			spread = {x = 100, y = 100, z = 100},
			seed = 329,
			octaves = 3,
			persist = 0.6
		},
		y_min = min,
		y_max = max,
		decoration = "farming:" .. name,
		spawn_by = spawnby,
		num_spawn_by = num,
	})
end


-- add crops to mapgen
register_plant("potato_3", 15, 40, nil, "", -1, farming.potato)
register_plant("tomato_7", 5, 20, nil, "", -1, farming.tomato)
register_plant("corn_7", 12, 22, nil, "", -1, farming.corn)
register_plant("coffee_5", 20, 45, {"default:dirt_with_dry_grass",
	"default:dirt_with_rainforest_litter"}, "", -1, farming.coffee)
register_plant("raspberry_4", 3, 10, nil, "", -1, farming.raspberry)
register_plant("rhubarb_3", 3, 15, nil, "", -1, farming.rhubarb)
register_plant("blueberry_4", 3, 10, nil, "", -1, farming.blueberry)
register_plant("beanbush", 18, 35, nil, "", -1, farming.beans)
register_plant("grapebush", 25, 45, nil, "", -1, farming.grapes)
register_plant("onion_5", 5, 22, nil, "", -1, farming.onion)
register_plant("garlic_5", 3, 30, nil, "group:tree", 1, farming.garlic)
register_plant("pea_5", 25, 50, nil, "", -1, farming.peas)
register_plant("beetroot_5", 1, 15, nil, "", -1, farming.beetroot)


if minetest.get_mapgen_setting("mg_name") == "v6" then

	register_plant("carrot_8", 1, 30, nil, "group:water", 1, farming.carrot)
	register_plant("cucumber_4", 1, 20, nil, "group:water", 1, farming.cucumber)
	register_plant("melon_8", 1, 20, nil, "group:water", 1, farming.melon)
	register_plant("pumpkin_8", 1, 20, nil, "group:water", 1, farming.pumpkin)
else
	-- v7 maps have a beach so plants growing near water is limited to 6 high
	register_plant("carrot_8", 1, 15, nil, "", -1, farming.carrot)
	register_plant("cucumber_4", 1, 10, nil, "", -1, farming.cucumber)
	register_plant("melon_8", 1, 6, {"default:dirt_with_dry_grass",
	"default:dirt_with_rainforest_litter"}, "", -1, farming.melon)
	register_plant("pumpkin_8", 1, 6, nil, "", -1, farming.pumpkin)
end

if farming.hemp then
minetest.register_decoration({
	deco_type = "simple",
	place_on = {"default:dirt_with_grass", "default:dirt_with_rainforest_litter"},
	sidelen = 16,
	noise_params = {
		offset = 0,
		scale = farming.rarety, -- 0.06,
		spread = {x = 100, y = 100, z = 100},
		seed = 420,
		octaves = 3,
		persist = 0.6
	},
	y_min = 3,
	y_max = 45,
	decoration = "farming:hemp_7",
	spawn_by = "group:tree",
	num_spawn_by = 1,
})
end

if farming.chili then
minetest.register_decoration({
	deco_type = "simple",
	place_on = {"default:dirt_with_grass", "default:dirt_with_rainforest_litter"},
	sidelen = 16,
	noise_params = {
		offset = 0,
		scale = farming.rarety, -- 0.06,
		spread = {x = 100, y = 100, z = 100},
		seed = 760,
		octaves = 3,
		persist = 0.6
	},
	y_min = 5,
	y_max = 35,
	decoration = {"farming:chili_8"},
	spawn_by = "group:tree",
	num_spawn_by = 1,
})
end

if farming.pepper then
minetest.register_decoration({
	deco_type = "simple",
	place_on = {"default:dirt_with_rainforest_litter"},
	sidelen = 16,
	noise_params = {
		offset = 0,
		scale = farming.rarety, -- 0.06,
		spread = {x = 100, y = 100, z = 100},
		seed = 933,
		octaves = 3,
		persist = 0.6
	},
	y_min = 5,
	y_max = 35,
	decoration = {"farming:pepper_5"},
	spawn_by = "group:tree",
	num_spawn_by = 1,
})
end

if farming.pineapple then
minetest.register_decoration({
	deco_type = "simple",
	place_on = {"default:dirt_with_dry_grass"},
	sidelen = 16,
	noise_params = {
		offset = 0,
		scale = farming.rarety, -- 0.06,
		spread = {x = 100, y = 100, z = 100},
		seed = 917,
		octaves = 3,
		persist = 0.6
	},
	y_min = 18,
	y_max = 30,
	decoration = {"farming:pineapple_8"},
})
end