From: Paul Ouellette Date: Wed, 23 Oct 2019 17:48:19 +0000 (-0400) Subject: Allow calling ItemStack with no arguments (#8783) X-Git-Tag: 5.2.0~320 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=904b05b0d31c707a7ecee8ca55c43a491d26439d;p=oweals%2Fminetest.git Allow calling ItemStack with no arguments (#8783) --- 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);