From 904b05b0d31c707a7ecee8ca55c43a491d26439d Mon Sep 17 00:00:00 2001 From: Paul Ouellette Date: Wed, 23 Oct 2019 13:48:19 -0400 Subject: Allow calling ItemStack with no arguments (#8783) --- src/script/lua_api/l_item.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/script/lua_api') 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); -- cgit v1.2.3