aboutsummaryrefslogtreecommitdiff
path: root/src/script
diff options
context:
space:
mode:
authorkwolekr <kwolekr@minetest.net>2013-11-30 00:27:39 -0500
committerkwolekr <kwolekr@minetest.net>2013-11-30 00:27:39 -0500
commitff7d7080e3ea2d2ca1669cb8c47c35a6c4753d39 (patch)
treee599ebf2496f7c57523774b3d7c49d5f6541cc5b /src/script
parent769b2d7c0582a6e294472aa9ac166d8d1064cd77 (diff)
downloadminetest-ff7d7080e3ea2d2ca1669cb8c47c35a6c4753d39.tar.gz
minetest-ff7d7080e3ea2d2ca1669cb8c47c35a6c4753d39.tar.bz2
minetest-ff7d7080e3ea2d2ca1669cb8c47c35a6c4753d39.zip
LuaVoxelManip: Add area parameters back to calc_lighting and set_lighting, made optional this time; also fixed a slight bug with night values being ignored
Diffstat (limited to 'src/script')
-rw-r--r--src/script/lua_api/l_vmanip.cpp23
1 files changed, 16 insertions, 7 deletions
diff --git a/src/script/lua_api/l_vmanip.cpp b/src/script/lua_api/l_vmanip.cpp
index 5228b7c06..92c04db3a 100644
--- a/src/script/lua_api/l_vmanip.cpp
+++ b/src/script/lua_api/l_vmanip.cpp
@@ -135,18 +135,23 @@ int LuaVoxelManip::l_calc_lighting(lua_State *L)
LuaVoxelManip *o = checkobject(L, 1);
if (!o->is_mapgen_vm)
return 0;
-
+
INodeDefManager *ndef = getServer(L)->getNodeDefManager();
EmergeManager *emerge = getServer(L)->getEmergeManager();
ManualMapVoxelManipulator *vm = o->vm;
+ v3s16 p1 = lua_istable(L, 2) ? read_v3s16(L, 2) :
+ vm->m_area.MinEdge + v3s16(0, 1, 0) * MAP_BLOCKSIZE;
+ v3s16 p2 = lua_istable(L, 3) ? read_v3s16(L, 3) :
+ vm->m_area.MaxEdge - v3s16(0, 1, 0) * MAP_BLOCKSIZE;
+ sortBoxVerticies(p1, p2);
+
Mapgen mg;
mg.vm = vm;
mg.ndef = ndef;
mg.water_level = emerge->params->water_level;
- mg.calcLighting(vm->m_area.MinEdge + v3s16(0, 1, 0) * MAP_BLOCKSIZE,
- vm->m_area.MaxEdge - v3s16(0, 1, 0) * MAP_BLOCKSIZE);
+ mg.calcLighting(p1, p2);
return 0;
}
@@ -164,16 +169,20 @@ int LuaVoxelManip::l_set_lighting(lua_State *L)
u8 light;
light = (getintfield_default(L, 2, "day", 0) & 0x0F);
- light |= (getintfield_default(L, 2, "night", 0) & 0x0F) << 8;
+ light |= (getintfield_default(L, 2, "night", 0) & 0x0F) << 4;
ManualMapVoxelManipulator *vm = o->vm;
+ v3s16 p1 = lua_istable(L, 3) ? read_v3s16(L, 3) :
+ vm->m_area.MinEdge + v3s16(0, 1, 0) * MAP_BLOCKSIZE;
+ v3s16 p2 = lua_istable(L, 4) ? read_v3s16(L, 4) :
+ vm->m_area.MaxEdge - v3s16(0, 1, 0) * MAP_BLOCKSIZE;
+ sortBoxVerticies(p1, p2);
+
Mapgen mg;
mg.vm = vm;
- mg.setLighting(vm->m_area.MinEdge + v3s16(0, 1, 0) * MAP_BLOCKSIZE,
- vm->m_area.MaxEdge - v3s16(0, 1, 0) * MAP_BLOCKSIZE,
- light);
+ mg.setLighting(p1, p2, light);
return 0;
}