aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHybridDog <ovvv@web.de>2018-08-02 20:54:44 +0200
committerParamat <paramat@users.noreply.github.com>2018-08-02 19:54:44 +0100
commit741e3efaf5c8e6d85178051d8655971a7f8b0bb9 (patch)
tree157c3e248fad09dd539b5c9049b482a3486df14a
parent6afbb06c7e552462ba2e682718488c9b13bfa0e5 (diff)
downloadminetest-741e3efaf5c8e6d85178051d8655971a7f8b0bb9.tar.gz
minetest-741e3efaf5c8e6d85178051d8655971a7f8b0bb9.tar.bz2
minetest-741e3efaf5c8e6d85178051d8655971a7f8b0bb9.zip
LuaVoxelManip: Throw warning or error instead of silently doing nothing (#7567)
Error on missing parameter. Warning when using a method on the incorrect type of LuaVoxelManip.
-rw-r--r--src/script/lua_api/l_vmanip.cpp20
1 files changed, 14 insertions, 6 deletions
diff --git a/src/script/lua_api/l_vmanip.cpp b/src/script/lua_api/l_vmanip.cpp
index 9eb246f1e..c92983bd3 100644
--- a/src/script/lua_api/l_vmanip.cpp
+++ b/src/script/lua_api/l_vmanip.cpp
@@ -91,7 +91,7 @@ int LuaVoxelManip::l_set_data(lua_State *L)
MMVManip *vm = o->vm;
if (!lua_istable(L, 2))
- return 0;
+ throw LuaError("VoxelManip:set_data called with missing parameter");
u32 volume = vm->m_area.getVolume();
for (u32 i = 0; i != volume; i++) {
@@ -185,8 +185,11 @@ int LuaVoxelManip::l_calc_lighting(lua_State *L)
NO_MAP_LOCK_REQUIRED;
LuaVoxelManip *o = checkobject(L, 1);
- if (!o->is_mapgen_vm)
+ if (!o->is_mapgen_vm) {
+ warningstream << "VoxelManip:calc_lighting called for a non-mapgen "
+ "VoxelManip object" << std::endl;
return 0;
+ }
const NodeDefManager *ndef = getServer(L)->getNodeDefManager();
EmergeManager *emerge = getServer(L)->getEmergeManager();
@@ -218,11 +221,14 @@ int LuaVoxelManip::l_set_lighting(lua_State *L)
NO_MAP_LOCK_REQUIRED;
LuaVoxelManip *o = checkobject(L, 1);
- if (!o->is_mapgen_vm)
+ if (!o->is_mapgen_vm) {
+ warningstream << "VoxelManip:set_lighting called for a non-mapgen "
+ "VoxelManip object" << std::endl;
return 0;
+ }
if (!lua_istable(L, 2))
- return 0;
+ throw LuaError("VoxelManip:set_lighting called with missing parameter");
u8 light;
light = (getintfield_default(L, 2, "day", 0) & 0x0F);
@@ -273,7 +279,8 @@ int LuaVoxelManip::l_set_light_data(lua_State *L)
MMVManip *vm = o->vm;
if (!lua_istable(L, 2))
- return 0;
+ throw LuaError("VoxelManip:set_light_data called with missing "
+ "parameter");
u32 volume = vm->m_area.getVolume();
for (u32 i = 0; i != volume; i++) {
@@ -321,7 +328,8 @@ int LuaVoxelManip::l_set_param2_data(lua_State *L)
MMVManip *vm = o->vm;
if (!lua_istable(L, 2))
- return 0;
+ throw LuaError("VoxelManip:set_param2_data called with missing "
+ "parameter");
u32 volume = vm->m_area.getVolume();
for (u32 i = 0; i != volume; i++) {