diff options
author | Paul Ouellette <oue.paul18@gmail.com> | 2019-10-23 13:48:19 -0400 |
---|---|---|
committer | SmallJoker <SmallJoker@users.noreply.github.com> | 2019-10-23 19:48:19 +0200 |
commit | 904b05b0d31c707a7ecee8ca55c43a491d26439d (patch) | |
tree | d9ada46f4b079bce900dd846f36bd5ded41760ec /src | |
parent | 524442fc5e9bc64952301b9ba25aefb0d9bf781b (diff) | |
download | minetest-904b05b0d31c707a7ecee8ca55c43a491d26439d.tar.gz minetest-904b05b0d31c707a7ecee8ca55c43a491d26439d.tar.bz2 minetest-904b05b0d31c707a7ecee8ca55c43a491d26439d.zip |
Allow calling ItemStack with no arguments (#8783)
Diffstat (limited to 'src')
-rw-r--r-- | src/script/lua_api/l_item.cpp | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/script/lua_api/l_item.cpp b/src/script/lua_api/l_item.cpp index f9708b560..a76e5527a 100644 --- a/src/script/lua_api/l_item.cpp +++ b/src/script/lua_api/l_item.cpp @@ -414,7 +414,9 @@ ItemStack& LuaItemStack::getItem() int LuaItemStack::create_object(lua_State *L) { NO_MAP_LOCK_REQUIRED; - ItemStack item = read_item(L, 1, getGameDef(L)->idef()); + ItemStack item; + if (!lua_isnone(L, 1)) + item = read_item(L, 1, getGameDef(L)->idef()); LuaItemStack *o = new LuaItemStack(item); *(void **)(lua_newuserdata(L, sizeof(void *))) = o; luaL_getmetatable(L, className); |