diff options
author | paramat <mat.gregory@virginmedia.com> | 2015-03-22 21:03:19 +0000 |
---|---|---|
committer | paramat <mat.gregory@virginmedia.com> | 2015-03-24 18:07:29 +0000 |
commit | d1681872bf03de1ac6c78c8dc8db0a3f081f5336 (patch) | |
tree | cf7319b10b8b9ed42d53e349a6d726108182ffa0 | |
parent | 4fbcfac6cf5f7404df62e94133388c601386d687 (diff) | |
download | minetest-d1681872bf03de1ac6c78c8dc8db0a3f081f5336.tar.gz minetest-d1681872bf03de1ac6c78c8dc8db0a3f081f5336.tar.bz2 minetest-d1681872bf03de1ac6c78c8dc8db0a3f081f5336.zip |
lua_api/l_mapgen: generate_ores/decorations: make p1, p2 optional
-rw-r--r-- | doc/lua_api.txt | 10 | ||||
-rw-r--r-- | src/script/lua_api/l_mapgen.cpp | 18 |
2 files changed, 18 insertions, 10 deletions
diff --git a/doc/lua_api.txt b/doc/lua_api.txt index 0b12652f1..bd85f0da5 100644 --- a/doc/lua_api.txt +++ b/doc/lua_api.txt @@ -1903,10 +1903,12 @@ and `minetest.auth_reload` call the authetification handler. * Sets the noiseparams setting of `name` to the noiseparams table specified in `noiseparams`. * `set_default` is an optional boolean (default: `true`) that specifies whether the setting should be applied to the default config or current active config -* `minetest.generate_ores(vm, p1, p2)` - * Generate all registered ores within the VoxelManip `vm` and in the area from p1 to p2. -* `minetest.generate_decorations(vm, p1, p2)` - * Generate all registered decorations within the VoxelManip `vm` and in the area from p1 to p2. +* `minetest.generate_ores(vm, pos1, pos2)` + * Generate all registered ores within the VoxelManip `vm` and in the area from `pos1` to `pos2`. + * `pos1` and `pos2` are optional and default to mapchunk minp and maxp. +* `minetest.generate_decorations(vm, pos1, pos2)` + * Generate all registered decorations within the VoxelManip `vm` and in the area from `pos1` to `pos2`. + * `pos1` and `pos2` are optional and default to mapchunk minp and maxp. * `minetest.clear_objects()` * clear all objects in the environments * `minetest.delete_area(pos1, pos2)` diff --git a/src/script/lua_api/l_mapgen.cpp b/src/script/lua_api/l_mapgen.cpp index 8806581de..172f2b5cc 100644 --- a/src/script/lua_api/l_mapgen.cpp +++ b/src/script/lua_api/l_mapgen.cpp @@ -801,10 +801,13 @@ int ModApiMapgen::l_generate_ores(lua_State *L) mg.vm = LuaVoxelManip::checkobject(L, 1)->vm; mg.ndef = getServer(L)->getNodeDefManager(); - u32 blockseed = Mapgen::getBlockSeed(mg.vm->m_area.MinEdge, mg.seed); + v3s16 pmin = lua_istable(L, 2) ? read_v3s16(L, 2) : + mg.vm->m_area.MinEdge + v3s16(1,1,1) * MAP_BLOCKSIZE; + v3s16 pmax = lua_istable(L, 3) ? read_v3s16(L, 3) : + mg.vm->m_area.MaxEdge - v3s16(1,1,1) * MAP_BLOCKSIZE; + sortBoxVerticies(pmin, pmax); - v3s16 pmin = read_v3s16(L, 2); - v3s16 pmax = read_v3s16(L, 3); + u32 blockseed = Mapgen::getBlockSeed(pmin, mg.seed); emerge->oremgr->placeAllOres(&mg, blockseed, pmin, pmax); @@ -821,10 +824,13 @@ int ModApiMapgen::l_generate_decorations(lua_State *L) mg.vm = LuaVoxelManip::checkobject(L, 1)->vm; mg.ndef = getServer(L)->getNodeDefManager(); - u32 blockseed = Mapgen::getBlockSeed(mg.vm->m_area.MinEdge, mg.seed); + v3s16 pmin = lua_istable(L, 2) ? read_v3s16(L, 2) : + mg.vm->m_area.MinEdge + v3s16(1,1,1) * MAP_BLOCKSIZE; + v3s16 pmax = lua_istable(L, 3) ? read_v3s16(L, 3) : + mg.vm->m_area.MaxEdge - v3s16(1,1,1) * MAP_BLOCKSIZE; + sortBoxVerticies(pmin, pmax); - v3s16 pmin = read_v3s16(L, 2); - v3s16 pmax = read_v3s16(L, 3); + u32 blockseed = Mapgen::getBlockSeed(pmin, mg.seed); emerge->decomgr->placeAllDecos(&mg, blockseed, pmin, pmax); |