Skip to content

Commit c3708b4

Browse files
committedDec 14, 2013
Add map feature generation notify Lua API
1 parent 83853cc commit c3708b4

12 files changed

+252
-151
lines changed
 

‎doc/lua_api.txt

+10
Original file line numberDiff line numberDiff line change
@@ -1289,6 +1289,10 @@ minetest.get_perlin(seeddiff, octaves, persistence, scale)
12891289
^ Return world-specific perlin noise (int(worldseed)+seeddiff)
12901290
minetest.get_voxel_manip()
12911291
^ Return voxel manipulator object
1292+
minetest.set_gen_notify(flags)
1293+
^ Set the types of on-generate notifications that should be collected
1294+
^ flags is a comma-delimited combination of:
1295+
^ dungeon, temple, cave_begin, cave_end, large_cave_begin, large_cave_end
12921296
minetest.get_mapgen_object(objectname)
12931297
^ Return requested mapgen object if available (see Mapgen objects)
12941298
minetest.set_mapgen_params(MapgenParams)
@@ -1894,6 +1898,12 @@ the current mapgen.
18941898
Returns an array containing the humidity values of nodes in the most recently generated chunk by the
18951899
current mapgen.
18961900

1901+
- gennotify
1902+
Returns a table mapping requested generation notification types to arrays of positions at which the
1903+
corresponding generated structures are located at within the current chunk. To set the capture of positions
1904+
of interest to be recorded on generate, use minetest.set_gen_notify().
1905+
Possible fields of the table returned are: dungeon, temple, cave_begin, cave_end, large_cave_begin, large_cave_end
1906+
18971907
Registered entities
18981908
--------------------
18991909
- Functions receive a "luaentity" as self:

‎src/cavegen.cpp

+24
Original file line numberDiff line numberDiff line change
@@ -110,9 +110,21 @@ void CaveV6::makeCave(v3s16 nmin, v3s16 nmax, int max_stone_height) {
110110
(float)(ps->next() % ar.Z) + 0.5
111111
);
112112

113+
int notifytype = large_cave ? GENNOTIFY_LARGECAVE_BEGIN : GENNOTIFY_CAVE_BEGIN;
114+
if (mg->gennotify & (1 << notifytype)) {
115+
std::vector <v3s16> *nvec = mg->gen_notifications[notifytype];
116+
nvec->push_back(v3s16(of.X + orp.X, of.Y + orp.Y, of.Z + orp.Z));
117+
}
118+
113119
// Generate some tunnel starting from orp
114120
for (u16 j = 0; j < tunnel_routepoints; j++)
115121
makeTunnel(j % dswitchint == 0);
122+
123+
notifytype = large_cave ? GENNOTIFY_LARGECAVE_END : GENNOTIFY_CAVE_END;
124+
if (mg->gennotify & (1 << notifytype)) {
125+
std::vector <v3s16> *nvec = mg->gen_notifications[notifytype];
126+
nvec->push_back(v3s16(of.X + orp.X, of.Y + orp.Y, of.Z + orp.Z));
127+
}
116128
}
117129

118130

@@ -347,9 +359,21 @@ void CaveV7::makeCave(v3s16 nmin, v3s16 nmax, int max_stone_height) {
347359
(float)(ps->next() % ar.Z) + 0.5
348360
);
349361

362+
int notifytype = large_cave ? GENNOTIFY_LARGECAVE_BEGIN : GENNOTIFY_CAVE_BEGIN;
363+
if (mg->gennotify & (1 << notifytype)) {
364+
std::vector <v3s16> *nvec = mg->gen_notifications[notifytype];
365+
nvec->push_back(v3s16(of.X + orp.X, of.Y + orp.Y, of.Z + orp.Z));
366+
}
367+
350368
// Generate some tunnel starting from orp
351369
for (u16 j = 0; j < tunnel_routepoints; j++)
352370
makeTunnel(j % dswitchint == 0);
371+
372+
notifytype = large_cave ? GENNOTIFY_LARGECAVE_END : GENNOTIFY_CAVE_END;
373+
if (mg->gennotify & (1 << notifytype)) {
374+
std::vector <v3s16> *nvec = mg->gen_notifications[notifytype];
375+
nvec->push_back(v3s16(of.X + orp.X, of.Y + orp.Y, of.Z + orp.Z));
376+
}
353377
}
354378

355379

0 commit comments

Comments
 (0)
Please sign in to comment.