This repository has been archived by the owner on Nov 3, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmapgen.lua
211 lines (175 loc) · 4.48 KB
/
mapgen.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
-- Clear stuff
minetest.clear_registered_biomes()
minetest.clear_registered_ores()
minetest.clear_registered_decorations()
-- Set mapgen settings
minetest.set_mapgen_setting("mg_name", "v7", true)
minetest.set_mapgen_setting("water_level", -15, true)
minetest.set_mapgen_setting("mg_flags", "caves,nodungeons,light,nodecorations", true)
-- Register biome
minetest.register_biome({
name = "moon",
--node_dust = "",
node_top = "moonrealm:dust",
depth_top = 1,
node_filler = "moonrealm:dust",
depth_filler = 2,
node_stone = "moonrealm:stone",
--node_water_top = "",
--depth_water_top = ,
node_water = "moonrealm:dust",
--node_river_water = "",
--node_riverbed = "",
--depth_riverbed = ,
y_min = -31000,
y_max = 31000,
heat_point = 50,
humidity_point = 50,
})
-- Register ores
-- Iron
minetest.register_ore({
ore_type = "scatter",
ore = "moonrealm:ironore",
wherein = "moonrealm:stone",
clust_scarcity = 7 * 7 * 7,
clust_num_ores = 5,
clust_size = 3,
y_min = -31000,
y_max = 0,
})
minetest.register_ore({
ore_type = "scatter",
ore = "moonrealm:ironore",
wherein = "moonrealm:stone",
clust_scarcity = 24 * 24 * 24,
clust_num_ores = 27,
clust_size = 6,
y_min = -31000,
y_max = -64,
})
-- Copper
minetest.register_ore({
ore_type = "scatter",
ore = "moonrealm:copperore",
wherein = "moonrealm:stone",
clust_scarcity = 12 * 12 * 12,
clust_num_ores = 4,
clust_size = 3,
y_min = -63,
y_max = -16,
})
minetest.register_ore({
ore_type = "scatter",
ore = "moonrealm:copperore",
wherein = "moonrealm:stone",
clust_scarcity = 9 * 9 * 9,
clust_num_ores = 5,
clust_size = 3,
y_min = -31000,
y_max = -64,
})
-- Gold
minetest.register_ore({
ore_type = "scatter",
ore = "moonrealm:goldore",
wherein = "moonrealm:stone",
clust_scarcity = 15 * 15 * 15,
clust_num_ores = 3,
clust_size = 2,
y_min = -255,
y_max = -64,
})
minetest.register_ore({
ore_type = "scatter",
ore = "moonrealm:goldore",
wherein = "moonrealm:stone",
clust_scarcity = 13 * 13 * 13,
clust_num_ores = 5,
clust_size = 3,
y_min = -31000,
y_max = -256,
})
-- Mese block
minetest.register_ore({
ore_type = "scatter",
ore = "default:mese",
wherein = "moonrealm:stone",
clust_scarcity = 18 * 18 * 18,
clust_num_ores = 3,
clust_size = 2,
y_min = -255,
y_max = -64,
})
minetest.register_ore({
ore_type = "scatter",
ore = "default:mese",
wherein = "moonrealm:stone",
clust_scarcity = 14 * 14 * 14,
clust_num_ores = 5,
clust_size = 3,
y_min = -31000,
y_max = -256,
})
-- Diamond
minetest.register_ore({
ore_type = "scatter",
ore = "moonrealm:diamondore",
wherein = "moonrealm:stone",
clust_scarcity = 17 * 17 * 17,
clust_num_ores = 4,
clust_size = 3,
y_min = -255,
y_max = -128,
})
minetest.register_ore({
ore_type = "scatter",
ore = "moonrealm:diamondore",
wherein = "moonrealm:stone",
clust_scarcity = 15 * 15 * 15,
clust_num_ores = 4,
clust_size = 3,
y_min = -31000,
y_max = -256,
})
-- Water ice
minetest.register_ore({
ore_type = "scatter",
ore = "moonrealm:waterice",
wherein = "moonrealm:dust",
clust_scarcity = 13 * 13 * 13,
clust_num_ores = 1,
clust_size = 1,
y_min = -31000,
y_max = 0,
})
-- Localise data buffer
local dbuf = {}
-- On generated function
-- Convert air nodes to mod vacuum nodes
minetest.register_on_generated(function(minp, maxp, seed)
local x0 = minp.x
local y0 = minp.y
local z0 = minp.z
local x1 = maxp.x
local y1 = maxp.y
local z1 = maxp.z
local c_air = minetest.CONTENT_AIR
local c_vacuum = minetest.get_content_id("moonrealm:vacuum")
local vm, emin, emax = minetest.get_mapgen_object("voxelmanip")
local area = VoxelArea:new{MinEdge = emin, MaxEdge = emax}
local data = vm:get_data(dbuf)
for z = z0, z1 do
for y = y0 - 1, y1 + 1 do
local vi = area:index(x0, y, z)
for x = x0, x1 do
if data[vi] == c_air then
data[vi] = c_vacuum
end
vi = vi + 1
end
end
end
vm:set_data(data)
vm:write_to_map(data)
end)