projects
/
oweals
/
minetest.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
b42493f
)
minetest.get_content_id: error if the node does not exist (#9458)
author
HybridDog
<3192173+HybridDog@users.noreply.github.com>
Wed, 11 Mar 2020 15:25:14 +0000
(16:25 +0100)
committer
GitHub
<noreply@github.com>
Wed, 11 Mar 2020 15:25:14 +0000
(16:25 +0100)
If a mod creator makes a typing mistake, this function now causes an error instead of returning the id of "ignore".
src/script/lua_api/l_item.cpp
patch
|
blob
|
history
diff --git
a/src/script/lua_api/l_item.cpp
b/src/script/lua_api/l_item.cpp
index a76e5527a17f45ca8b36e48266b82df2a4deb082..0c174feca3fe5e25b49ecc4fca68059b70b743d4 100644
(file)
--- 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, c
ontent_id
);
return 1; /* number of results */
}