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

@ -97,7 +97,6 @@ minetest.register_nodedef_defaults({
post_effect_color = {a=0, r=0, g=0, b=0}, post_effect_color = {a=0, r=0, g=0, b=0},
paramtype = "none", paramtype = "none",
is_ground_content = false, is_ground_content = false,
light_propagates = false,
sunlight_propagates = false, sunlight_propagates = false,
walkable = true, walkable = true,
pointable = true, pointable = true,
@ -133,7 +132,6 @@ minetest.register_nodedef_defaults({
minetest.register_node("air", { minetest.register_node("air", {
drawtype = "airlike", drawtype = "airlike",
paramtype = "light", paramtype = "light",
light_propagates = true,
sunlight_propagates = true, sunlight_propagates = true,
walkable = false, walkable = false,
pointable = false, pointable = false,
@ -145,7 +143,6 @@ minetest.register_node("air", {
minetest.register_node("ignore", { minetest.register_node("ignore", {
drawtype = "airlike", drawtype = "airlike",
paramtype = "none", paramtype = "none",
light_propagates = false,
sunlight_propagates = false, sunlight_propagates = false,
walkable = false, walkable = false,
pointable = false, pointable = false,

@ -261,7 +261,6 @@
-- post_effect_color = {a=0, r=0, g=0, b=0}, -- post_effect_color = {a=0, r=0, g=0, b=0},
-- paramtype = "none", -- paramtype = "none",
-- is_ground_content = false, -- is_ground_content = false,
-- light_propagates = false,
-- sunlight_propagates = false, -- sunlight_propagates = false,
-- walkable = true, -- walkable = true,
-- pointable = true, -- pointable = true,
@ -889,7 +888,6 @@ minetest.register_node("default:junglegrass", {
visual_scale = 1.3, visual_scale = 1.3,
tile_images = {"default_junglegrass.png"}, tile_images = {"default_junglegrass.png"},
inventory_image = "default_junglegrass.png", inventory_image = "default_junglegrass.png",
light_propagates = true,
paramtype = "light", paramtype = "light",
walkable = false, walkable = false,
material = minetest.digprop_leaveslike(1.0), material = minetest.digprop_leaveslike(1.0),
@ -901,7 +899,6 @@ minetest.register_node("default:leaves", {
visual_scale = 1.3, visual_scale = 1.3,
tile_images = {"default_leaves.png"}, tile_images = {"default_leaves.png"},
inventory_image = minetest.inventorycube("default_leaves.png"), inventory_image = minetest.inventorycube("default_leaves.png"),
light_propagates = true,
paramtype = "light", paramtype = "light",
material = minetest.digprop_leaveslike(1.0), material = minetest.digprop_leaveslike(1.0),
extra_dug_item = 'node "sapling" 1', extra_dug_item = 'node "sapling" 1',
@ -921,7 +918,6 @@ minetest.register_node("default:papyrus", {
drawtype = "plantlike", drawtype = "plantlike",
tile_images = {"default_papyrus.png"}, tile_images = {"default_papyrus.png"},
inventory_image = "default_papyrus.png", inventory_image = "default_papyrus.png",
light_propagates = true,
paramtype = "light", paramtype = "light",
is_ground_content = true, is_ground_content = true,
walkable = false, walkable = false,
@ -941,7 +937,6 @@ minetest.register_node("default:glass", {
drawtype = "glasslike", drawtype = "glasslike",
tile_images = {"default_glass.png"}, tile_images = {"default_glass.png"},
inventory_image = minetest.inventorycube("default_glass.png"), inventory_image = minetest.inventorycube("default_glass.png"),
light_propagates = true,
paramtype = "light", paramtype = "light",
sunlight_propagates = true, sunlight_propagates = true,
is_ground_content = true, is_ground_content = true,
@ -952,7 +947,6 @@ minetest.register_node("default:fence_wood", {
drawtype = "fencelike", drawtype = "fencelike",
tile_images = {"default_wood.png"}, tile_images = {"default_wood.png"},
inventory_image = "default_fence.png", inventory_image = "default_fence.png",
light_propagates = true,
paramtype = "light", paramtype = "light",
is_ground_content = true, is_ground_content = true,
selection_box = { selection_box = {
@ -967,7 +961,6 @@ minetest.register_node("default:rail", {
drawtype = "raillike", drawtype = "raillike",
tile_images = {"default_rail.png", "default_rail_curved.png", "default_rail_t_junction.png", "default_rail_crossing.png"}, tile_images = {"default_rail.png", "default_rail_curved.png", "default_rail_t_junction.png", "default_rail_crossing.png"},
inventory_image = "default_rail.png", inventory_image = "default_rail.png",
light_propagates = true,
paramtype = "light", paramtype = "light",
is_ground_content = true, is_ground_content = true,
walkable = false, walkable = false,
@ -982,7 +975,6 @@ minetest.register_node("default:ladder", {
drawtype = "signlike", drawtype = "signlike",
tile_images = {"default_ladder.png"}, tile_images = {"default_ladder.png"},
inventory_image = "default_ladder.png", inventory_image = "default_ladder.png",
light_propagates = true,
paramtype = "light", paramtype = "light",
is_ground_content = true, is_ground_content = true,
wall_mounted = true, wall_mounted = true,
@ -1026,7 +1018,6 @@ minetest.register_node("default:water_flowing", {
alpha = WATER_ALPHA, alpha = WATER_ALPHA,
inventory_image = minetest.inventorycube("default_water.png"), inventory_image = minetest.inventorycube("default_water.png"),
paramtype = "light", paramtype = "light",
light_propagates = true,
walkable = false, walkable = false,
pointable = false, pointable = false,
diggable = false, diggable = false,
@ -1048,7 +1039,6 @@ minetest.register_node("default:water_source", {
alpha = WATER_ALPHA, alpha = WATER_ALPHA,
inventory_image = minetest.inventorycube("default_water.png"), inventory_image = minetest.inventorycube("default_water.png"),
paramtype = "light", paramtype = "light",
light_propagates = true,
walkable = false, walkable = false,
pointable = false, pointable = false,
diggable = false, diggable = false,
@ -1069,7 +1059,6 @@ minetest.register_node("default:lava_flowing", {
tile_images = {"default_lava.png"}, tile_images = {"default_lava.png"},
inventory_image = minetest.inventorycube("default_lava.png"), inventory_image = minetest.inventorycube("default_lava.png"),
paramtype = "light", paramtype = "light",
light_propagates = false,
light_source = LIGHT_MAX - 1, light_source = LIGHT_MAX - 1,
walkable = false, walkable = false,
pointable = false, pointable = false,
@ -1092,7 +1081,6 @@ minetest.register_node("default:lava_source", {
tile_images = {"default_lava.png"}, tile_images = {"default_lava.png"},
inventory_image = minetest.inventorycube("default_lava.png"), inventory_image = minetest.inventorycube("default_lava.png"),
paramtype = "light", paramtype = "light",
light_propagates = false,
light_source = LIGHT_MAX - 1, light_source = LIGHT_MAX - 1,
walkable = false, walkable = false,
pointable = false, pointable = false,
@ -1116,7 +1104,6 @@ minetest.register_node("default:torch", {
tile_images = {"default_torch_on_floor.png", "default_torch_on_ceiling.png", "default_torch.png"}, tile_images = {"default_torch_on_floor.png", "default_torch_on_ceiling.png", "default_torch.png"},
inventory_image = "default_torch_on_floor.png", inventory_image = "default_torch_on_floor.png",
paramtype = "light", paramtype = "light",
light_propagates = true,
sunlight_propagates = true, sunlight_propagates = true,
walkable = false, walkable = false,
wall_mounted = true, wall_mounted = true,
@ -1136,7 +1123,6 @@ minetest.register_node("default:sign_wall", {
tile_images = {"default_sign_wall.png"}, tile_images = {"default_sign_wall.png"},
inventory_image = "default_sign_wall.png", inventory_image = "default_sign_wall.png",
paramtype = "light", paramtype = "light",
light_propagates = true,
sunlight_propagates = true, sunlight_propagates = true,
walkable = false, walkable = false,
wall_mounted = true, wall_mounted = true,
@ -1224,7 +1210,6 @@ minetest.register_node("default:sapling", {
tile_images = {"default_sapling.png"}, tile_images = {"default_sapling.png"},
inventory_image = "default_sapling.png", inventory_image = "default_sapling.png",
paramtype = "light", paramtype = "light",
light_propagates = true,
walkable = false, walkable = false,
material = minetest.digprop_constanttime(0.0), material = minetest.digprop_constanttime(0.0),
furnace_burntime = 10, furnace_burntime = 10,
@ -1236,7 +1221,6 @@ minetest.register_node("default:apple", {
tile_images = {"default_apple.png"}, tile_images = {"default_apple.png"},
inventory_image = "default_apple.png", inventory_image = "default_apple.png",
paramtype = "light", paramtype = "light",
light_propagates = true,
sunlight_propagates = true, sunlight_propagates = true,
walkable = false, walkable = false,
dug_item = 'craft "apple" 1', dug_item = 'craft "apple" 1',

@ -35,13 +35,19 @@ LuaError::LuaError(lua_State *L, const std::string &s)
{ {
m_s = "LuaError: "; m_s = "LuaError: ";
m_s += s + "\n"; 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"); lua_getfield(L, LUA_GLOBALSINDEX, "debug");
if(lua_istable(L, -1)){ if(lua_istable(L, -1)){
lua_getfield(L, -1, "traceback"); lua_getfield(L, -1, "traceback");
if(lua_isfunction(L, -1)){ if(lua_isfunction(L, -1)){
lua_call(L, 0, 1); lua_call(L, 0, 1);
if(lua_isstring(L, -1)){ if(lua_isstring(L, -1)){
m_s += lua_tostring(L, -1); s += lua_tostring(L, -1);
} }
lua_pop(L, 1); lua_pop(L, 1);
} }
@ -50,6 +56,7 @@ LuaError::LuaError(lua_State *L, const std::string &s)
} }
} }
lua_pop(L, 1); lua_pop(L, 1);
return s;
} }
void script_error(lua_State *L, const char *fmt, ...) void script_error(lua_State *L, const char *fmt, ...)

@ -41,6 +41,7 @@ public:
lua_State* script_init(); lua_State* script_init();
void script_deinit(lua_State *L); void script_deinit(lua_State *L);
std::string script_get_backtrace(lua_State *L);
void script_error(lua_State *L, const char *fmt, ...); void script_error(lua_State *L, const char *fmt, ...);
bool script_load(lua_State *L, const char *path); bool script_load(lua_State *L, const char *path);

@ -455,6 +455,18 @@ static void setfloatfield(lua_State *L, int table,
lua_setfield(L, table, fieldname); 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 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 // 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, "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); getboolfield(L, nodedef_table, "sunlight_propagates", f.sunlight_propagates);
// This is used for collision detection. // This is used for collision detection.
// Also for general solidness queries. // Also for general solidness queries.