aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPerttu Ahola <celeron55@gmail.com>2011-12-04 03:45:02 +0200
committerPerttu Ahola <celeron55@gmail.com>2011-12-04 03:45:02 +0200
commit3e95b8a1587ebce9443d4d716645798bfbb630f2 (patch)
treeb39df9c89aa2e9849ccffce96e92d6b7e456731d /src
parente8539d4dae46c926553ef0fa76afeaf6be6ecafb (diff)
downloadminetest-3e95b8a1587ebce9443d4d716645798bfbb630f2.tar.gz
minetest-3e95b8a1587ebce9443d4d716645798bfbb630f2.tar.bz2
minetest-3e95b8a1587ebce9443d4d716645798bfbb630f2.zip
Determine light_propagates from paramtype
Diffstat (limited to 'src')
-rw-r--r--src/script.cpp9
-rw-r--r--src/script.h1
-rw-r--r--src/scriptapi.cpp16
3 files changed, 24 insertions, 2 deletions
diff --git a/src/script.cpp b/src/script.cpp
index 8b1b7013e..14c23e009 100644
--- a/src/script.cpp
+++ b/src/script.cpp
@@ -35,13 +35,19 @@ LuaError::LuaError(lua_State *L, const std::string &s)
{
m_s = "LuaError: ";
m_s += s + "\n";
+ m_s += script_get_backtrace(L);
+}
+
+std::string script_get_backtrace(lua_State *L)
+{
+ std::string s;
lua_getfield(L, LUA_GLOBALSINDEX, "debug");
if(lua_istable(L, -1)){
lua_getfield(L, -1, "traceback");
if(lua_isfunction(L, -1)){
lua_call(L, 0, 1);
if(lua_isstring(L, -1)){
- m_s += lua_tostring(L, -1);
+ s += lua_tostring(L, -1);
}
lua_pop(L, 1);
}
@@ -50,6 +56,7 @@ LuaError::LuaError(lua_State *L, const std::string &s)
}
}
lua_pop(L, 1);
+ return s;
}
void script_error(lua_State *L, const char *fmt, ...)
diff --git a/src/script.h b/src/script.h
index 3c056ae35..3bf5342f5 100644
--- a/src/script.h
+++ b/src/script.h
@@ -41,6 +41,7 @@ public:
lua_State* script_init();
void script_deinit(lua_State *L);
+std::string script_get_backtrace(lua_State *L);
void script_error(lua_State *L, const char *fmt, ...);
bool script_load(lua_State *L, const char *path);
diff --git a/src/scriptapi.cpp b/src/scriptapi.cpp
index d7382b98b..ffbce9167 100644
--- a/src/scriptapi.cpp
+++ b/src/scriptapi.cpp
@@ -455,6 +455,18 @@ static void setfloatfield(lua_State *L, int table,
lua_setfield(L, table, fieldname);
}
+static void warn_if_field_exists(lua_State *L, int table,
+ const char *fieldname, const std::string &message)
+{
+ lua_getfield(L, table, fieldname);
+ if(!lua_isnil(L, -1)){
+ infostream<<script_get_backtrace(L)<<std::endl;
+ infostream<<"WARNING: field \""<<fieldname<<"\": "
+ <<message<<std::endl;
+ }
+ lua_pop(L, 1);
+}
+
/*
Inventory stuff
*/
@@ -1019,7 +1031,9 @@ static int l_register_node(lua_State *L)
// True for all ground-like things like stone and mud, false for eg. trees
getboolfield(L, nodedef_table, "is_ground_content", f.is_ground_content);
- getboolfield(L, nodedef_table, "light_propagates", f.light_propagates);
+ f.light_propagates = (f.param_type == CPT_LIGHT);
+ warn_if_field_exists(L, nodedef_table, "light_propagates",
+ "deprecated: determined from paramtype");
getboolfield(L, nodedef_table, "sunlight_propagates", f.sunlight_propagates);
// This is used for collision detection.
// Also for general solidness queries.