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
parent
769b2d7c05
commit
ff7d7080e3
|
@ -1815,18 +1815,19 @@ methods:
|
||||||
- update_map(): Update map after writing chunk back to map.
|
- update_map(): Update map after writing chunk back to map.
|
||||||
^ To be used only by VoxelManip objects created by the mod itself; not a VoxelManip that was
|
^ To be used only by VoxelManip objects created by the mod itself; not a VoxelManip that was
|
||||||
^ retrieved from minetest.get_mapgen_object
|
^ retrieved from minetest.get_mapgen_object
|
||||||
- set_lighting(light): Set the lighting within the VoxelManip
|
- set_lighting(light, p1, p2): Set the lighting within the VoxelManip to a uniform value
|
||||||
^ light is a table, {day=<0...15>, night=<0...15>}
|
^ light is a table, {day=<0...15>, night=<0...15>}
|
||||||
^ To be used only by a VoxelManip object from minetest.get_mapgen_object
|
^ To be used only by a VoxelManip object from minetest.get_mapgen_object
|
||||||
|
^ (p1, p2) is the area in which lighting is set; defaults to the whole area if left out
|
||||||
- get_light_data(): Gets the light data read into the VoxelManip object
|
- get_light_data(): Gets the light data read into the VoxelManip object
|
||||||
^ Returns an array (indicies 1 to volume) of integers ranging from 0 to 255
|
^ Returns an array (indicies 1 to volume) of integers ranging from 0 to 255
|
||||||
^ Each value is the bitwise combination of day and night light values (0..15 each)
|
^ Each value is the bitwise combination of day and night light values (0..15 each)
|
||||||
^ light = day + (night * 16)
|
^ light = day + (night * 16)
|
||||||
- set_light_data(light_data): Sets the param1 (light) contents of each node in the VoxelManip
|
- set_light_data(light_data): Sets the param1 (light) contents of each node in the VoxelManip
|
||||||
^ expects lighting data in the same format that get_light_data() returns
|
^ expects lighting data in the same format that get_light_data() returns
|
||||||
- calc_lighting(): Calculate lighting within the VoxelManip
|
- calc_lighting(p1, p2): Calculate lighting within the VoxelManip
|
||||||
^ To be used only by a VoxelManip object from minetest.get_mapgen_object
|
^ To be used only by a VoxelManip object from minetest.get_mapgen_object
|
||||||
|
^ (p1, p2) is the area in which lighting is set; defaults to the whole area if left out
|
||||||
- update_liquids(): Update liquid flow
|
- update_liquids(): Update liquid flow
|
||||||
|
|
||||||
VoxelArea: A helper class for voxel areas
|
VoxelArea: A helper class for voxel areas
|
||||||
|
|
|
@ -140,13 +140,18 @@ int LuaVoxelManip::l_calc_lighting(lua_State *L)
|
||||||
EmergeManager *emerge = getServer(L)->getEmergeManager();
|
EmergeManager *emerge = getServer(L)->getEmergeManager();
|
||||||
ManualMapVoxelManipulator *vm = o->vm;
|
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;
|
Mapgen mg;
|
||||||
mg.vm = vm;
|
mg.vm = vm;
|
||||||
mg.ndef = ndef;
|
mg.ndef = ndef;
|
||||||
mg.water_level = emerge->params->water_level;
|
mg.water_level = emerge->params->water_level;
|
||||||
|
|
||||||
mg.calcLighting(vm->m_area.MinEdge + v3s16(0, 1, 0) * MAP_BLOCKSIZE,
|
mg.calcLighting(p1, p2);
|
||||||
vm->m_area.MaxEdge - v3s16(0, 1, 0) * MAP_BLOCKSIZE);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -164,16 +169,20 @@ int LuaVoxelManip::l_set_lighting(lua_State *L)
|
||||||
|
|
||||||
u8 light;
|
u8 light;
|
||||||
light = (getintfield_default(L, 2, "day", 0) & 0x0F);
|
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;
|
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;
|
Mapgen mg;
|
||||||
mg.vm = vm;
|
mg.vm = vm;
|
||||||
|
|
||||||
mg.setLighting(vm->m_area.MinEdge + v3s16(0, 1, 0) * MAP_BLOCKSIZE,
|
mg.setLighting(p1, p2, light);
|
||||||
vm->m_area.MaxEdge - v3s16(0, 1, 0) * MAP_BLOCKSIZE,
|
|
||||||
light);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue