1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-09-15 18:57:08 +00:00

Determine light_propagates from paramtype

This commit is contained in:
Perttu Ahola 2011-12-04 03:45:02 +02:00
parent e8539d4dae
commit 3e95b8a158
5 changed files with 24 additions and 21 deletions

View file

@ -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, ...)

View file

@ -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);

View file

@ -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.