Allow calling ItemStack with no arguments (#8783)
authorPaul Ouellette <oue.paul18@gmail.com>
Wed, 23 Oct 2019 17:48:19 +0000 (13:48 -0400)
committerSmallJoker <SmallJoker@users.noreply.github.com>
Wed, 23 Oct 2019 17:48:19 +0000 (19:48 +0200)
src/script/lua_api/l_item.cpp

index f9708b560f4f580bbbd5693702c60ca7ea9fdcdf..a76e5527a17f45ca8b36e48266b82df2a4deb082 100644 (file)
@@ -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);