aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHybridDog <3192173+HybridDog@users.noreply.github.com>2020-03-11 16:25:14 +0100
committerGitHub <noreply@github.com>2020-03-11 16:25:14 +0100
commitfd4daefb29f2922937849a207812fe368260f43e (patch)
tree0d959c58ce85fa70a6b8e5567b41e56e646ae122
parentb42493fb4c40611020c9ded9b7af5b96dc4148bd (diff)
downloadminetest-fd4daefb29f2922937849a207812fe368260f43e.tar.gz
minetest-fd4daefb29f2922937849a207812fe368260f43e.tar.bz2
minetest-fd4daefb29f2922937849a207812fe368260f43e.zip
minetest.get_content_id: error if the node does not exist (#9458)
If a mod creator makes a typing mistake, this function now causes an error instead of returning the id of "ignore".
-rw-r--r--src/script/lua_api/l_item.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/script/lua_api/l_item.cpp b/src/script/lua_api/l_item.cpp
index a76e5527a..0c174feca 100644
--- a/src/script/lua_api/l_item.cpp
+++ b/src/script/lua_api/l_item.cpp
@@ -612,9 +612,11 @@ int ModApiItemMod::l_get_content_id(lua_State *L)
std::string name = luaL_checkstring(L, 1);
const NodeDefManager *ndef = getGameDef(L)->getNodeDefManager();
- content_t c = ndef->getId(name);
+ content_t content_id;
+ if (!ndef->getId(name, content_id))
+ throw LuaError("Unknown node: " + name);
- lua_pushinteger(L, c);
+ lua_pushinteger(L, content_id);
return 1; /* number of results */
}