mirror of
https://github.com/luanti-org/luanti.git
synced 2025-06-27 16:36:03 +00:00
Minor script api fixes/cleanups
This commit is contained in:
parent
5b6bc8a12b
commit
524d446757
11 changed files with 37 additions and 36 deletions
|
@ -1061,17 +1061,7 @@ int ModApiEnvMod::l_get_perlin_map(lua_State *L)
|
|||
// returns voxel manipulator
|
||||
int ModApiEnvMod::l_get_voxel_manip(lua_State *L)
|
||||
{
|
||||
GET_ENV_PTR;
|
||||
|
||||
Map *map = &(env->getMap());
|
||||
LuaVoxelManip *o = (lua_istable(L, 1) && lua_istable(L, 2)) ?
|
||||
new LuaVoxelManip(map, read_v3s16(L, 1), read_v3s16(L, 2)) :
|
||||
new LuaVoxelManip(map);
|
||||
|
||||
*(void **)(lua_newuserdata(L, sizeof(void *))) = o;
|
||||
luaL_getmetatable(L, "VoxelManip");
|
||||
lua_setmetatable(L, -2);
|
||||
return 1;
|
||||
return LuaVoxelManip::create_object(L);
|
||||
}
|
||||
|
||||
// clear_objects([options])
|
||||
|
|
|
@ -621,10 +621,7 @@ int ModApiMapgen::l_get_mapgen_object(lua_State *L)
|
|||
MMVManip *vm = mg->vm;
|
||||
|
||||
// VoxelManip object
|
||||
LuaVoxelManip *o = new LuaVoxelManip(vm, true);
|
||||
*(void **)(lua_newuserdata(L, sizeof(void *))) = o;
|
||||
luaL_getmetatable(L, "VoxelManip");
|
||||
lua_setmetatable(L, -2);
|
||||
LuaVoxelManip::create(L, vm, true);
|
||||
|
||||
// emerged min pos
|
||||
push_v3s16(L, vm->m_area.MinEdge);
|
||||
|
|
|
@ -111,12 +111,14 @@ int LuaVoxelManip::l_set_data(lua_State *L)
|
|||
|
||||
int LuaVoxelManip::l_write_to_map(lua_State *L)
|
||||
{
|
||||
MAP_LOCK_REQUIRED;
|
||||
GET_ENV_PTR;
|
||||
|
||||
LuaVoxelManip *o = checkObject<LuaVoxelManip>(L, 1);
|
||||
bool update_light = !lua_isboolean(L, 2) || readParam<bool>(L, 2);
|
||||
|
||||
GET_ENV_PTR;
|
||||
if (o->vm->isOrphan())
|
||||
return 0;
|
||||
|
||||
ServerMap *map = &(env->getServerMap());
|
||||
|
||||
std::map<v3s16, MapBlock*> modified_blocks;
|
||||
|
@ -420,6 +422,14 @@ int LuaVoxelManip::create_object(lua_State *L)
|
|||
return 1;
|
||||
}
|
||||
|
||||
void LuaVoxelManip::create(lua_State *L, MMVManip *mmvm, bool is_mapgen_vm)
|
||||
{
|
||||
LuaVoxelManip *o = new LuaVoxelManip(mmvm, is_mapgen_vm);
|
||||
*(void **)(lua_newuserdata(L, sizeof(void *))) = o;
|
||||
luaL_getmetatable(L, className);
|
||||
lua_setmetatable(L, -2);
|
||||
}
|
||||
|
||||
void *LuaVoxelManip::packIn(lua_State *L, int idx)
|
||||
{
|
||||
LuaVoxelManip *o = checkObject<LuaVoxelManip>(L, idx);
|
||||
|
@ -442,10 +452,7 @@ void LuaVoxelManip::packOut(lua_State *L, void *ptr)
|
|||
if (env)
|
||||
vm->reparent(&(env->getMap()));
|
||||
|
||||
LuaVoxelManip *o = new LuaVoxelManip(vm, false);
|
||||
*(void **)(lua_newuserdata(L, sizeof(void *))) = o;
|
||||
luaL_getmetatable(L, className);
|
||||
lua_setmetatable(L, -2);
|
||||
create(L, vm, false);
|
||||
}
|
||||
|
||||
void LuaVoxelManip::Register(lua_State *L)
|
||||
|
|
|
@ -71,6 +71,8 @@ public:
|
|||
// LuaVoxelManip()
|
||||
// Creates a LuaVoxelManip and leaves it on top of stack
|
||||
static int create_object(lua_State *L);
|
||||
// Not callable from Lua
|
||||
static void create(lua_State *L, MMVManip *mmvm, bool is_mapgen_vm);
|
||||
|
||||
static void *packIn(lua_State *L, int idx);
|
||||
static void packOut(lua_State *L, void *ptr);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue