From 1ed559bd2418dc34689160df09af8f779300ee9f Mon Sep 17 00:00:00 2001 From: Matthew I Date: Mon, 30 Jul 2012 09:45:26 -0400 Subject: Allow digging of unknown nodes This allows the removal of nodes with unknown types. get_item_callback() (C++) would fail if a node has an unknown type. Now it will try using the callback from minetest.nodedef_default in this case. Also, minetest.node_dig() (Lua) was altered to always allow digging when the node definition is empty (i.e. unknown node). --- src/scriptapi.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/scriptapi.cpp b/src/scriptapi.cpp index b8b3cb73a..a1975971f 100644 --- a/src/scriptapi.cpp +++ b/src/scriptapi.cpp @@ -5510,6 +5510,8 @@ void scriptapi_on_player_receive_fields(lua_State *L, // If that is nil or on error, return false and stack is unchanged // If that is a function, returns true and pushes the // function onto the stack +// If minetest.registered_items[name] doesn't exist, minetest.nodedef_default +// is tried instead so unknown items can still be manipulated to some degree static bool get_item_callback(lua_State *L, const char *name, const char *callbackname) { @@ -5522,9 +5524,15 @@ static bool get_item_callback(lua_State *L, // Should be a table if(lua_type(L, -1) != LUA_TTABLE) { + // Report error and clean up errorstream<<"Item \""<