Allow calling ItemStack with no arguments (#8783)

This commit is contained in:
Paul Ouellette 2019-10-23 13:48:19 -04:00 committed by SmallJoker
parent 524442fc5e
commit 904b05b0d3
1 changed files with 3 additions and 1 deletions

View 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);