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".
This commit is contained in:
HybridDog 2020-03-11 16:25:14 +01:00 committed by GitHub
parent b42493fb4c
commit fd4daefb29
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -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 */
}