Add definable node_stone to biome API, mgv5, mgv7. Reduce and correct depth of mgv7...
[oweals/minetest.git] / src / script / lua_api / l_mapgen.cpp
1 /*
2 Minetest
3 Copyright (C) 2013 celeron55, Perttu Ahola <celeron55@gmail.com>
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as published by
7 the Free Software Foundation; either version 2.1 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 GNU Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public License along
16 with this program; if not, write to the Free Software Foundation, Inc.,
17 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 */
19
20 #include "lua_api/l_mapgen.h"
21 #include "lua_api/l_internal.h"
22 #include "lua_api/l_vmanip.h"
23 #include "common/c_converter.h"
24 #include "common/c_content.h"
25 #include "util/serialize.h"
26 #include "server.h"
27 #include "environment.h"
28 #include "emerge.h"
29 #include "mg_biome.h"
30 #include "mg_ore.h"
31 #include "mg_decoration.h"
32 #include "mg_schematic.h"
33 #include "mapgen_v5.h"
34 #include "mapgen_v7.h"
35 #include "settings.h"
36 #include "main.h"
37 #include "log.h"
38
39
40 struct EnumString ModApiMapgen::es_BiomeTerrainType[] =
41 {
42         {BIOME_TYPE_NORMAL, "normal"},
43         {BIOME_TYPE_LIQUID, "liquid"},
44         {BIOME_TYPE_NETHER, "nether"},
45         {BIOME_TYPE_AETHER, "aether"},
46         {BIOME_TYPE_FLAT,   "flat"},
47         {0, NULL},
48 };
49
50 struct EnumString ModApiMapgen::es_DecorationType[] =
51 {
52         {DECO_SIMPLE,    "simple"},
53         {DECO_SCHEMATIC, "schematic"},
54         {DECO_LSYSTEM,   "lsystem"},
55         {0, NULL},
56 };
57
58 struct EnumString ModApiMapgen::es_MapgenObject[] =
59 {
60         {MGOBJ_VMANIP,    "voxelmanip"},
61         {MGOBJ_HEIGHTMAP, "heightmap"},
62         {MGOBJ_BIOMEMAP,  "biomemap"},
63         {MGOBJ_HEATMAP,   "heatmap"},
64         {MGOBJ_HUMIDMAP,  "humiditymap"},
65         {MGOBJ_GENNOTIFY, "gennotify"},
66         {0, NULL},
67 };
68
69 struct EnumString ModApiMapgen::es_OreType[] =
70 {
71         {ORE_SCATTER,  "scatter"},
72         {ORE_SHEET,    "sheet"},
73         {ORE_CLAYLIKE, "claylike"},
74         {0, NULL},
75 };
76
77 struct EnumString ModApiMapgen::es_Rotation[] =
78 {
79         {ROTATE_0,    "0"},
80         {ROTATE_90,   "90"},
81         {ROTATE_180,  "180"},
82         {ROTATE_270,  "270"},
83         {ROTATE_RAND, "random"},
84         {0, NULL},
85 };
86
87
88 static void read_schematic_replacements(lua_State *L,
89         std::map<std::string, std::string> &replace_names, int index)
90 {
91         lua_pushnil(L);
92         while (lua_next(L, index)) {
93                 std::string replace_from;
94                 std::string replace_to;
95
96                 if (lua_istable(L, -1)) { // Old {{"x", "y"}, ...} format
97                         lua_rawgeti(L, -1, 1);
98                         replace_from = lua_tostring(L, -1);
99                         lua_pop(L, 1);
100
101                         lua_rawgeti(L, -1, 2);
102                         replace_to = lua_tostring(L, -1);
103                         lua_pop(L, 1);
104                 } else { // New {x = "y", ...} format
105                         replace_from = lua_tostring(L, -2);
106                         replace_to = lua_tostring(L, -1);
107                 }
108
109                 replace_names[replace_from] = replace_to;
110                 lua_pop(L, 1);
111         }
112 }
113
114
115 // get_mapgen_object(objectname)
116 // returns the requested object used during map generation
117 int ModApiMapgen::l_get_mapgen_object(lua_State *L)
118 {
119         const char *mgobjstr = lua_tostring(L, 1);
120
121         int mgobjint;
122         if (!string_to_enum(es_MapgenObject, mgobjint, mgobjstr ? mgobjstr : ""))
123                 return 0;
124
125         enum MapgenObject mgobj = (MapgenObject)mgobjint;
126
127         EmergeManager *emerge = getServer(L)->getEmergeManager();
128         Mapgen *mg = emerge->getCurrentMapgen();
129         if (!mg)
130                 return 0;
131
132         size_t maplen = mg->csize.X * mg->csize.Z;
133
134         switch (mgobj) {
135                 case MGOBJ_VMANIP: {
136                         ManualMapVoxelManipulator *vm = mg->vm;
137
138                         // VoxelManip object
139                         LuaVoxelManip *o = new LuaVoxelManip(vm, true);
140                         *(void **)(lua_newuserdata(L, sizeof(void *))) = o;
141                         luaL_getmetatable(L, "VoxelManip");
142                         lua_setmetatable(L, -2);
143
144                         // emerged min pos
145                         push_v3s16(L, vm->m_area.MinEdge);
146
147                         // emerged max pos
148                         push_v3s16(L, vm->m_area.MaxEdge);
149
150                         return 3;
151                 }
152                 case MGOBJ_HEIGHTMAP: {
153                         if (!mg->heightmap)
154                                 return 0;
155
156                         lua_newtable(L);
157                         for (size_t i = 0; i != maplen; i++) {
158                                 lua_pushinteger(L, mg->heightmap[i]);
159                                 lua_rawseti(L, -2, i + 1);
160                         }
161
162                         return 1;
163                 }
164                 case MGOBJ_BIOMEMAP: {
165                         if (!mg->biomemap)
166                                 return 0;
167
168                         lua_newtable(L);
169                         for (size_t i = 0; i != maplen; i++) {
170                                 lua_pushinteger(L, mg->biomemap[i]);
171                                 lua_rawseti(L, -2, i + 1);
172                         }
173
174                         return 1;
175                 }
176                 case MGOBJ_HEATMAP: { // Mapgen V7 specific objects
177                 case MGOBJ_HUMIDMAP:
178                         if (strcmp(emerge->params.mg_name.c_str(), "v7"))
179                                 return 0;
180
181                         MapgenV7 *mgv7 = (MapgenV7 *)mg;
182
183                         float *arr = (mgobj == MGOBJ_HEATMAP) ?
184                                 mgv7->noise_heat->result : mgv7->noise_humidity->result;
185                         if (!arr)
186                                 return 0;
187
188                         lua_newtable(L);
189                         for (size_t i = 0; i != maplen; i++) {
190                                 lua_pushnumber(L, arr[i]);
191                                 lua_rawseti(L, -2, i + 1);
192                         }
193
194                         return 1;
195                 }
196                 case MGOBJ_GENNOTIFY: {
197                         lua_newtable(L);
198                         for (int i = 0; flagdesc_gennotify[i].name; i++) {
199                                 if (!(emerge->gennotify & flagdesc_gennotify[i].flag))
200                                         continue;
201
202                                 std::vector<v3s16> *posvec = mg->gen_notifications[i];
203                                 if (!posvec)
204                                         return 0;
205
206                                 lua_newtable(L);
207                                 for (unsigned int j = 0; j != posvec->size(); j++) {
208                                         push_v3s16(L, (*posvec)[j]);
209                                         lua_rawseti(L, -2, j + 1);
210                                 }
211                                 lua_setfield(L, -2, flagdesc_gennotify[i].name);
212
213                                 posvec->clear();
214                         }
215
216                         return 1;
217                 }
218         }
219
220         return 0;
221 }
222
223 // set_mapgen_params(params)
224 // set mapgen parameters
225 int ModApiMapgen::l_set_mapgen_params(lua_State *L)
226 {
227         if (!lua_istable(L, 1))
228                 return 0;
229
230         EmergeManager *emerge = getServer(L)->getEmergeManager();
231         assert(emerge);
232
233         std::string flagstr;
234         u32 flags = 0, flagmask = 0;
235
236         lua_getfield(L, 1, "mgname");
237         if (lua_isstring(L, -1)) {
238                 emerge->params.mg_name = std::string(lua_tostring(L, -1));
239                 delete emerge->params.sparams;
240                 emerge->params.sparams = NULL;
241         }
242
243         lua_getfield(L, 1, "seed");
244         if (lua_isnumber(L, -1))
245                 emerge->params.seed = lua_tointeger(L, -1);
246
247         lua_getfield(L, 1, "water_level");
248         if (lua_isnumber(L, -1))
249                 emerge->params.water_level = lua_tointeger(L, -1);
250
251         lua_getfield(L, 1, "flagmask");
252         if (lua_isstring(L, -1)) {
253                 flagstr = lua_tostring(L, -1);
254                 emerge->params.flags &= ~readFlagString(flagstr, flagdesc_mapgen, NULL);
255                 errorstream << "set_mapgen_params(): flagmask field is deprecated, "
256                         "see lua_api.txt" << std::endl;
257         }
258
259         if (getflagsfield(L, 1, "flags", flagdesc_mapgen, &flags, &flagmask)) {
260                 emerge->params.flags &= ~flagmask;
261                 emerge->params.flags |= flags;
262         }
263
264         return 0;
265 }
266
267 // set_noiseparam_defaults({np1={noise params}, ...})
268 // set default values for noise parameters if not present in global settings
269 int ModApiMapgen::l_set_noiseparam_defaults(lua_State *L)
270 {
271         NoiseParams np;
272         std::string val, name;
273
274         if (!lua_istable(L, 1))
275                 return 0;
276
277         lua_pushnil(L);
278         while (lua_next(L, 1)) {
279                 if (read_noiseparams_nc(L, -1, &np)) {
280                         if (!serializeStructToString(&val, NOISEPARAMS_FMT_STR, &np))
281                                 continue;
282                         if (!lua_isstring(L, -2))
283                                 continue;
284
285                         name = lua_tostring(L, -2);
286                         g_settings->setDefault(name, val);
287                 }
288                 lua_pop(L, 1);
289         }
290
291         return 0;
292 }
293
294 // set_gen_notify(string)
295 int ModApiMapgen::l_set_gen_notify(lua_State *L)
296 {
297         u32 flags = 0, flagmask = 0;
298
299         if (read_flags(L, 1, flagdesc_gennotify, &flags, &flagmask)) {
300                 EmergeManager *emerge = getServer(L)->getEmergeManager();
301                 emerge->gennotify = flags;
302         }
303
304         return 0;
305 }
306
307 // register_biome({lots of stuff})
308 int ModApiMapgen::l_register_biome(lua_State *L)
309 {
310         int index = 1;
311         luaL_checktype(L, index, LUA_TTABLE);
312
313         NodeResolver *resolver = getServer(L)->getNodeDefManager()->getResolver();
314         BiomeManager *bmgr     = getServer(L)->getEmergeManager()->biomemgr;
315
316         enum BiomeType biometype = (BiomeType)getenumfield(L, index, "type",
317                 es_BiomeTerrainType, BIOME_TYPE_NORMAL);
318         Biome *b = bmgr->create(biometype);
319
320         b->name           = getstringfield_default(L, index, "name", "");
321         b->depth_top      = getintfield_default(L, index, "depth_top",    1);
322         b->depth_filler   = getintfield_default(L, index, "depth_filler", 3);
323         b->height_min     = getintfield_default(L, index, "height_min",   0);
324         b->height_max     = getintfield_default(L, index, "height_max",   0);
325         b->heat_point     = getfloatfield_default(L, index, "heat_point",     0.);
326         b->humidity_point = getfloatfield_default(L, index, "humidity_point", 0.);
327         b->flags          = 0; //reserved
328
329         u32 id = bmgr->add(b);
330         if (id == (u32)-1) {
331                 delete b;
332                 return 0;
333         }
334
335         // Pend node resolutions only if insertion succeeded
336         resolver->addNode(getstringfield_default(L, index, "node_top", ""),
337                  "mapgen_dirt_with_grass", CONTENT_AIR, &b->c_top);
338         resolver->addNode(getstringfield_default(L, index, "node_filler", ""),
339                 "mapgen_dirt", CONTENT_AIR, &b->c_filler);
340         resolver->addNode(getstringfield_default(L, index, "node_stone", ""),
341                 "mapgen_stone", CONTENT_AIR, &b->c_stone);
342         resolver->addNode(getstringfield_default(L, index, "node_water", ""),
343                 "mapgen_water_source", CONTENT_AIR, &b->c_water);
344         resolver->addNode(getstringfield_default(L, index, "node_dust", ""),
345                 "air", CONTENT_IGNORE, &b->c_dust);
346         resolver->addNode(getstringfield_default(L, index, "node_dust_water", ""),
347                 "mapgen_water_source", CONTENT_IGNORE, &b->c_dust_water);
348
349         verbosestream << "register_biome: " << b->name << std::endl;
350
351         lua_pushinteger(L, id);
352         return 1;
353 }
354
355 // register_decoration({lots of stuff})
356 int ModApiMapgen::l_register_decoration(lua_State *L)
357 {
358         int index = 1;
359         luaL_checktype(L, index, LUA_TTABLE);
360
361         INodeDefManager *ndef      = getServer(L)->getNodeDefManager();
362         NodeResolver *resolver     = getServer(L)->getNodeDefManager()->getResolver();
363         DecorationManager *decomgr = getServer(L)->getEmergeManager()->decomgr;
364         BiomeManager *biomemgr     = getServer(L)->getEmergeManager()->biomemgr;
365
366         enum DecorationType decotype = (DecorationType)getenumfield(L, index,
367                                 "deco_type", es_DecorationType, -1);
368
369         Decoration *deco = decomgr->create(decotype);
370         if (!deco) {
371                 errorstream << "register_decoration: decoration placement type "
372                         << decotype << " not implemented";
373                 return 0;
374         }
375         
376         deco->name       = getstringfield_default(L, index, "name", "");
377         deco->fill_ratio = getfloatfield_default(L, index, "fill_ratio", 0.02);
378         deco->sidelen    = getintfield_default(L, index, "sidelen", 8);
379         if (deco->sidelen <= 0) {
380                 errorstream << "register_decoration: sidelen must be "
381                         "greater than 0" << std::endl;
382                 delete deco;
383                 return 0;
384         }
385
386         //// Get node name(s) to place decoration on
387         std::vector<const char *> place_on_names;
388         getstringlistfield(L, index, "place_on", place_on_names);
389         for (size_t i = 0; i != place_on_names.size(); i++)
390                 resolver->addNodeList(place_on_names[i], &deco->c_place_on);
391
392         //// Get NoiseParams to define how decoration is placed
393         lua_getfield(L, index, "noise_params");
394         deco->np = read_noiseparams(L, -1);
395         lua_pop(L, 1);
396
397         //// Get biomes associated with this decoration (if any)
398         std::vector<const char *> biome_list;
399         getstringlistfield(L, index, "biomes", biome_list);
400         for (size_t i = 0; i != biome_list.size(); i++) {
401                 Biome *b = (Biome *)biomemgr->getByName(biome_list[i]);
402                 if (!b)
403                         continue;
404
405                 deco->biomes.insert(b->id);
406         }
407
408         //// Handle decoration type-specific parameters
409         bool success = false;
410         switch (decotype) {
411                 case DECO_SIMPLE:
412                         success = regDecoSimple(L, resolver, (DecoSimple *)deco);
413                         break;
414                 case DECO_SCHEMATIC:
415                         success = regDecoSchematic(L, ndef, (DecoSchematic *)deco);
416                         break;
417                 case DECO_LSYSTEM:
418                         break;
419         }
420
421         if (!success) {
422                 delete deco;
423                 return 0;
424         }
425
426         u32 id = decomgr->add(deco);
427         if (id == (u32)-1) {
428                 delete deco;
429                 return 0;
430         }
431
432         lua_pushinteger(L, id);
433         return 1;
434 }
435
436 bool ModApiMapgen::regDecoSimple(lua_State *L,
437                 NodeResolver *resolver, DecoSimple *deco)
438 {
439         int index = 1;
440
441         deco->deco_height     = getintfield_default(L, index, "height", 1);
442         deco->deco_height_max = getintfield_default(L, index, "height_max", 0);
443         deco->nspawnby        = getintfield_default(L, index, "num_spawn_by", -1);
444
445         if (deco->deco_height <= 0) {
446                 errorstream << "register_decoration: simple decoration height"
447                         " must be greater than 0" << std::endl;
448                 return false;
449         }
450
451         std::vector<const char *> deco_names;
452         getstringlistfield(L, index, "decoration", deco_names);
453         if (deco_names.size() == 0) {
454                 errorstream << "register_decoration: no decoration nodes "
455                         "defined" << std::endl;
456                 return false;
457         }
458
459         std::vector<const char *> spawnby_names;
460         getstringlistfield(L, index, "spawn_by", spawnby_names);
461         if (deco->nspawnby != -1 && spawnby_names.size() == 0) {
462                 errorstream << "register_decoration: no spawn_by nodes defined,"
463                         " but num_spawn_by specified" << std::endl;
464                 return false;
465         }
466
467         for (size_t i = 0; i != deco_names.size(); i++)
468                 resolver->addNodeList(deco_names[i], &deco->c_decos);
469         for (size_t i = 0; i != spawnby_names.size(); i++)
470                 resolver->addNodeList(spawnby_names[i], &deco->c_spawnby);
471
472         return true;
473 }
474
475 bool ModApiMapgen::regDecoSchematic(lua_State *L, INodeDefManager *ndef,
476         DecoSchematic *deco)
477 {
478         int index = 1;
479
480         deco->flags = 0;
481         getflagsfield(L, index, "flags", flagdesc_deco_schematic, &deco->flags, NULL);
482
483         deco->rotation = (Rotation)getenumfield(L, index, "rotation",
484                 es_Rotation, ROTATE_0);
485
486         std::map<std::string, std::string> replace_names;
487         lua_getfield(L, index, "replacements");
488         if (lua_istable(L, -1))
489                 read_schematic_replacements(L, replace_names, lua_gettop(L));
490         lua_pop(L, 1);
491
492         Schematic *schem = new Schematic;
493         lua_getfield(L, index, "schematic");
494         if (!get_schematic(L, -1, schem, ndef, replace_names)) {
495                 lua_pop(L, 1);
496                 delete schem;
497                 return false;
498         }
499         lua_pop(L, 1);
500
501         deco->schematic = schem;
502
503         return true;
504 }
505
506 // register_ore({lots of stuff})
507 int ModApiMapgen::l_register_ore(lua_State *L)
508 {
509         int index = 1;
510         luaL_checktype(L, index, LUA_TTABLE);
511
512         NodeResolver *resolver = getServer(L)->getNodeDefManager()->getResolver();
513         OreManager *oremgr     = getServer(L)->getEmergeManager()->oremgr;
514
515         enum OreType oretype = (OreType)getenumfield(L, index,
516                                 "ore_type", es_OreType, ORE_SCATTER);
517         Ore *ore = oremgr->create(oretype);
518         if (!ore) {
519                 errorstream << "register_ore: ore_type " << oretype << " not implemented";
520                 return 0;
521         }
522
523         ore->name           = getstringfield_default(L, index, "name", "");
524         ore->ore_param2     = (u8)getintfield_default(L, index, "ore_param2", 0);
525         ore->clust_scarcity = getintfield_default(L, index, "clust_scarcity", 1);
526         ore->clust_num_ores = getintfield_default(L, index, "clust_num_ores", 1);
527         ore->clust_size     = getintfield_default(L, index, "clust_size", 0);
528         ore->height_min     = getintfield_default(L, index, "height_min", 0);
529         ore->height_max     = getintfield_default(L, index, "height_max", 0);
530         ore->nthresh        = getfloatfield_default(L, index, "noise_threshhold", 0);
531         ore->noise          = NULL;
532         ore->flags          = 0;
533
534         if (ore->clust_scarcity <= 0 || ore->clust_num_ores <= 0) {
535                 errorstream << "register_ore: clust_scarcity and clust_num_ores"
536                         "must be greater than 0" << std::endl;
537                 delete ore;
538                 return 0;
539         }
540
541         getflagsfield(L, index, "flags", flagdesc_ore, &ore->flags, NULL);
542
543         lua_getfield(L, index, "noise_params");
544         ore->np = read_noiseparams(L, -1);
545         lua_pop(L, 1);
546
547         u32 id = oremgr->add(ore);
548         if (id == (u32)-1) {
549                 delete ore;
550                 return 0;
551         }
552
553         std::vector<const char *> wherein_names;
554         getstringlistfield(L, index, "wherein", wherein_names);
555         for (size_t i = 0; i != wherein_names.size(); i++)
556                 resolver->addNodeList(wherein_names[i], &ore->c_wherein);
557
558         resolver->addNode(getstringfield_default(L, index, "ore", ""),
559                 "", CONTENT_AIR, &ore->c_ore);
560
561         lua_pushinteger(L, id);
562         return 1;
563 }
564
565 // create_schematic(p1, p2, probability_list, filename)
566 int ModApiMapgen::l_create_schematic(lua_State *L)
567 {
568         Schematic schem;
569
570         Map *map = &(getEnv(L)->getMap());
571         INodeDefManager *ndef = getServer(L)->getNodeDefManager();
572
573         v3s16 p1 = read_v3s16(L, 1);
574         v3s16 p2 = read_v3s16(L, 2);
575         sortBoxVerticies(p1, p2);
576
577         std::vector<std::pair<v3s16, u8> > prob_list;
578         if (lua_istable(L, 3)) {
579                 lua_pushnil(L);
580                 while (lua_next(L, 3)) {
581                         if (lua_istable(L, -1)) {
582                                 lua_getfield(L, -1, "pos");
583                                 v3s16 pos = read_v3s16(L, -1);
584                                 lua_pop(L, 1);
585
586                                 u8 prob = getintfield_default(L, -1, "prob", MTSCHEM_PROB_ALWAYS);
587                                 prob_list.push_back(std::make_pair(pos, prob));
588                         }
589
590                         lua_pop(L, 1);
591                 }
592         }
593
594         std::vector<std::pair<s16, u8> > slice_prob_list;
595         if (lua_istable(L, 5)) {
596                 lua_pushnil(L);
597                 while (lua_next(L, 5)) {
598                         if (lua_istable(L, -1)) {
599                                 s16 ypos = getintfield_default(L, -1, "ypos", 0);
600                                 u8 prob  = getintfield_default(L, -1, "prob", MTSCHEM_PROB_ALWAYS);
601                                 slice_prob_list.push_back(std::make_pair(ypos, prob));
602                         }
603
604                         lua_pop(L, 1);
605                 }
606         }
607
608         const char *filename = luaL_checkstring(L, 4);
609
610         if (!schem.getSchematicFromMap(map, p1, p2)) {
611                 errorstream << "create_schematic: failed to get schematic "
612                         "from map" << std::endl;
613                 return 0;
614         }
615
616         schem.applyProbabilities(p1, &prob_list, &slice_prob_list);
617
618         schem.saveSchematicToFile(filename, ndef);
619         actionstream << "create_schematic: saved schematic file '"
620                 << filename << "'." << std::endl;
621
622         return 1;
623 }
624
625 // place_schematic(p, schematic, rotation, replacement)
626 int ModApiMapgen::l_place_schematic(lua_State *L)
627 {
628         Schematic schem;
629
630         Map *map = &(getEnv(L)->getMap());
631         INodeDefManager *ndef = getServer(L)->getNodeDefManager();
632
633         //// Read position
634         v3s16 p = read_v3s16(L, 1);
635
636         //// Read rotation
637         int rot = ROTATE_0;
638         if (lua_isstring(L, 3))
639                 string_to_enum(es_Rotation, rot, std::string(lua_tostring(L, 3)));
640
641         //// Read force placement
642         bool force_placement = true;
643         if (lua_isboolean(L, 5))
644                 force_placement = lua_toboolean(L, 5);
645
646         //// Read node replacements
647         std::map<std::string, std::string> replace_names;
648         if (lua_istable(L, 4))
649                 read_schematic_replacements(L, replace_names, 4);
650
651         //// Read schematic
652         if (!get_schematic(L, 2, &schem, ndef, replace_names)) {
653                 errorstream << "place_schematic: failed to get schematic" << std::endl;
654                 return 0;
655         }
656
657         schem.placeStructure(map, p, 0, (Rotation)rot, force_placement, ndef);
658
659         return 1;
660 }
661
662 void ModApiMapgen::Initialize(lua_State *L, int top)
663 {
664         API_FCT(get_mapgen_object);
665
666         API_FCT(set_mapgen_params);
667         API_FCT(set_noiseparam_defaults);
668         API_FCT(set_gen_notify);
669
670         API_FCT(register_biome);
671         API_FCT(register_decoration);
672         API_FCT(register_ore);
673
674         API_FCT(create_schematic);
675         API_FCT(place_schematic);
676 }