From 3e95b8a1587ebce9443d4d716645798bfbb630f2 Mon Sep 17 00:00:00 2001 From: Perttu Ahola Date: Sun, 4 Dec 2011 03:45:02 +0200 Subject: Determine light_propagates from paramtype --- data/builtin.lua | 3 --- data/mods/default/init.lua | 16 ---------------- src/script.cpp | 9 ++++++++- src/script.h | 1 + src/scriptapi.cpp | 16 +++++++++++++++- 5 files changed, 24 insertions(+), 21 deletions(-) diff --git a/data/builtin.lua b/data/builtin.lua index 2f167acfa..555cc3ab8 100644 --- a/data/builtin.lua +++ b/data/builtin.lua @@ -97,7 +97,6 @@ minetest.register_nodedef_defaults({ post_effect_color = {a=0, r=0, g=0, b=0}, paramtype = "none", is_ground_content = false, - light_propagates = false, sunlight_propagates = false, walkable = true, pointable = true, @@ -133,7 +132,6 @@ minetest.register_nodedef_defaults({ minetest.register_node("air", { drawtype = "airlike", paramtype = "light", - light_propagates = true, sunlight_propagates = true, walkable = false, pointable = false, @@ -145,7 +143,6 @@ minetest.register_node("air", { minetest.register_node("ignore", { drawtype = "airlike", paramtype = "none", - light_propagates = false, sunlight_propagates = false, walkable = false, pointable = false, diff --git a/data/mods/default/init.lua b/data/mods/default/init.lua index 100b9f1c8..a843063ef 100644 --- a/data/mods/default/init.lua +++ b/data/mods/default/init.lua @@ -261,7 +261,6 @@ -- post_effect_color = {a=0, r=0, g=0, b=0}, -- paramtype = "none", -- is_ground_content = false, --- light_propagates = false, -- sunlight_propagates = false, -- walkable = true, -- pointable = true, @@ -889,7 +888,6 @@ minetest.register_node("default:junglegrass", { visual_scale = 1.3, tile_images = {"default_junglegrass.png"}, inventory_image = "default_junglegrass.png", - light_propagates = true, paramtype = "light", walkable = false, material = minetest.digprop_leaveslike(1.0), @@ -901,7 +899,6 @@ minetest.register_node("default:leaves", { visual_scale = 1.3, tile_images = {"default_leaves.png"}, inventory_image = minetest.inventorycube("default_leaves.png"), - light_propagates = true, paramtype = "light", material = minetest.digprop_leaveslike(1.0), extra_dug_item = 'node "sapling" 1', @@ -921,7 +918,6 @@ minetest.register_node("default:papyrus", { drawtype = "plantlike", tile_images = {"default_papyrus.png"}, inventory_image = "default_papyrus.png", - light_propagates = true, paramtype = "light", is_ground_content = true, walkable = false, @@ -941,7 +937,6 @@ minetest.register_node("default:glass", { drawtype = "glasslike", tile_images = {"default_glass.png"}, inventory_image = minetest.inventorycube("default_glass.png"), - light_propagates = true, paramtype = "light", sunlight_propagates = true, is_ground_content = true, @@ -952,7 +947,6 @@ minetest.register_node("default:fence_wood", { drawtype = "fencelike", tile_images = {"default_wood.png"}, inventory_image = "default_fence.png", - light_propagates = true, paramtype = "light", is_ground_content = true, selection_box = { @@ -967,7 +961,6 @@ minetest.register_node("default:rail", { drawtype = "raillike", tile_images = {"default_rail.png", "default_rail_curved.png", "default_rail_t_junction.png", "default_rail_crossing.png"}, inventory_image = "default_rail.png", - light_propagates = true, paramtype = "light", is_ground_content = true, walkable = false, @@ -982,7 +975,6 @@ minetest.register_node("default:ladder", { drawtype = "signlike", tile_images = {"default_ladder.png"}, inventory_image = "default_ladder.png", - light_propagates = true, paramtype = "light", is_ground_content = true, wall_mounted = true, @@ -1026,7 +1018,6 @@ minetest.register_node("default:water_flowing", { alpha = WATER_ALPHA, inventory_image = minetest.inventorycube("default_water.png"), paramtype = "light", - light_propagates = true, walkable = false, pointable = false, diggable = false, @@ -1048,7 +1039,6 @@ minetest.register_node("default:water_source", { alpha = WATER_ALPHA, inventory_image = minetest.inventorycube("default_water.png"), paramtype = "light", - light_propagates = true, walkable = false, pointable = false, diggable = false, @@ -1069,7 +1059,6 @@ minetest.register_node("default:lava_flowing", { tile_images = {"default_lava.png"}, inventory_image = minetest.inventorycube("default_lava.png"), paramtype = "light", - light_propagates = false, light_source = LIGHT_MAX - 1, walkable = false, pointable = false, @@ -1092,7 +1081,6 @@ minetest.register_node("default:lava_source", { tile_images = {"default_lava.png"}, inventory_image = minetest.inventorycube("default_lava.png"), paramtype = "light", - light_propagates = false, light_source = LIGHT_MAX - 1, walkable = 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"}, inventory_image = "default_torch_on_floor.png", paramtype = "light", - light_propagates = true, sunlight_propagates = true, walkable = false, wall_mounted = true, @@ -1136,7 +1123,6 @@ minetest.register_node("default:sign_wall", { tile_images = {"default_sign_wall.png"}, inventory_image = "default_sign_wall.png", paramtype = "light", - light_propagates = true, sunlight_propagates = true, walkable = false, wall_mounted = true, @@ -1224,7 +1210,6 @@ minetest.register_node("default:sapling", { tile_images = {"default_sapling.png"}, inventory_image = "default_sapling.png", paramtype = "light", - light_propagates = true, walkable = false, material = minetest.digprop_constanttime(0.0), furnace_burntime = 10, @@ -1236,7 +1221,6 @@ minetest.register_node("default:apple", { tile_images = {"default_apple.png"}, inventory_image = "default_apple.png", paramtype = "light", - light_propagates = true, sunlight_propagates = true, walkable = false, dug_item = 'craft "apple" 1', 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<