Skip to content

Commit

Permalink
minetest.get_content_id: error if the node does not exist (#9458)
Browse files Browse the repository at this point in the history
If a mod creator makes a typing mistake, this function now causes an error instead of returning the id of "ignore".
  • Loading branch information
HybridDog committed Mar 11, 2020
1 parent b42493f commit fd4daef
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/script/lua_api/l_item.cpp
Expand Up @@ -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 */
}

Expand Down

0 comments on commit fd4daef

Please sign in to comment.