diff options
author | kwolekr <kwolekr@minetest.net> | 2015-01-04 22:37:20 -0500 |
---|---|---|
committer | kwolekr <kwolekr@minetest.net> | 2015-01-04 22:38:48 -0500 |
commit | bdcf03ae36553f4c7ba48d18ef8d67f05590dd60 (patch) | |
tree | 1b2a0603fedebb23ca08ec7de96846810de2a32f /src/script | |
parent | a92c0830113e7a32d056fabd3cbd58cedbde684a (diff) | |
download | minetest-bdcf03ae36553f4c7ba48d18ef8d67f05590dd60.tar.gz minetest-bdcf03ae36553f4c7ba48d18ef8d67f05590dd60.tar.bz2 minetest-bdcf03ae36553f4c7ba48d18ef8d67f05590dd60.zip |
Add minetest.generate_ores() and minetest.generate_decorations()
Diffstat (limited to 'src/script')
-rw-r--r-- | src/script/lua_api/l_mapgen.cpp | 39 | ||||
-rw-r--r-- | src/script/lua_api/l_mapgen.h | 6 | ||||
-rw-r--r-- | src/script/lua_api/l_vmanip.h | 3 |
3 files changed, 47 insertions, 1 deletions
diff --git a/src/script/lua_api/l_mapgen.cpp b/src/script/lua_api/l_mapgen.cpp index 7d9987e72..bff8ccfe6 100644 --- a/src/script/lua_api/l_mapgen.cpp +++ b/src/script/lua_api/l_mapgen.cpp @@ -810,6 +810,42 @@ int ModApiMapgen::l_create_schematic(lua_State *L) return 1; } +// generate_ores(vm, [ore_id]) +int ModApiMapgen::l_generate_ores(lua_State *L) +{ + EmergeManager *emerge = getServer(L)->getEmergeManager(); + + Mapgen mg; + mg.seed = emerge->params.seed; + mg.vm = LuaVoxelManip::checkobject(L, 1)->vm; + mg.ndef = getServer(L)->getNodeDefManager(); + + u32 blockseed = Mapgen::getBlockSeed(mg.vm->m_area.MinEdge, mg.seed); + + emerge->oremgr->placeAllOres(&mg, blockseed, + mg.vm->m_area.MinEdge, mg.vm->m_area.MaxEdge); + + return 0; +} + +// generate_decorations(vm, [deco_id]) +int ModApiMapgen::l_generate_decorations(lua_State *L) +{ + EmergeManager *emerge = getServer(L)->getEmergeManager(); + + Mapgen mg; + mg.seed = emerge->params.seed; + mg.vm = LuaVoxelManip::checkobject(L, 1)->vm; + mg.ndef = getServer(L)->getNodeDefManager(); + + u32 blockseed = Mapgen::getBlockSeed(mg.vm->m_area.MinEdge, mg.seed); + + emerge->decomgr->placeAllDecos(&mg, blockseed, + mg.vm->m_area.MinEdge, mg.vm->m_area.MaxEdge); + + return 0; +} + // place_schematic(p, schematic, rotation, replacement) int ModApiMapgen::l_place_schematic(lua_State *L) { @@ -864,6 +900,9 @@ void ModApiMapgen::Initialize(lua_State *L, int top) API_FCT(clear_registered_decorations); API_FCT(clear_registered_ores); + API_FCT(generate_ores); + API_FCT(generate_decorations); + API_FCT(create_schematic); API_FCT(place_schematic); } diff --git a/src/script/lua_api/l_mapgen.h b/src/script/lua_api/l_mapgen.h index e98838470..dd96a009e 100644 --- a/src/script/lua_api/l_mapgen.h +++ b/src/script/lua_api/l_mapgen.h @@ -62,6 +62,12 @@ private: // clear_registered_decorations() static int l_clear_registered_decorations(lua_State *L); + // generate_ores(vm) + static int l_generate_ores(lua_State *L); + + // generate_decorations(vm) + static int l_generate_decorations(lua_State *L); + // clear_registered_ores static int l_clear_registered_ores(lua_State *L); diff --git a/src/script/lua_api/l_vmanip.h b/src/script/lua_api/l_vmanip.h index 887b18663..82c807240 100644 --- a/src/script/lua_api/l_vmanip.h +++ b/src/script/lua_api/l_vmanip.h @@ -33,7 +33,6 @@ class ManualMapVoxelManipulator; */ class LuaVoxelManip : public ModApiBase { private: - ManualMapVoxelManipulator *vm; std::map<v3s16, MapBlock *> modified_blocks; bool is_mapgen_vm; @@ -65,6 +64,8 @@ private: static int l_get_emerged_area(lua_State *L); public: + ManualMapVoxelManipulator *vm; + LuaVoxelManip(ManualMapVoxelManipulator *mmvm, bool is_mapgen_vm); LuaVoxelManip(Map *map, v3s16 p1, v3s16 p2); LuaVoxelManip(Map *map); |