Skip to content

Commit fd4daef

Browse files
authoredMar 11, 2020
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".
1 parent b42493f commit fd4daef

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed
 

‎src/script/lua_api/l_item.cpp

+4-2
Original file line numberDiff line numberDiff line change
@@ -612,9 +612,11 @@ int ModApiItemMod::l_get_content_id(lua_State *L)
612612
std::string name = luaL_checkstring(L, 1);
613613

614614
const NodeDefManager *ndef = getGameDef(L)->getNodeDefManager();
615-
content_t c = ndef->getId(name);
615+
content_t content_id;
616+
if (!ndef->getId(name, content_id))
617+
throw LuaError("Unknown node: " + name);
616618

617-
lua_pushinteger(L, c);
619+
lua_pushinteger(L, content_id);
618620
return 1; /* number of results */
619621
}
620622

0 commit comments

Comments
 (0)
Please sign in to comment.