Skip to content
Permalink
Browse files

Allow calling ItemStack with no arguments (#8783)

  • Loading branch information
pauloue authored and SmallJoker committed Oct 23, 2019
1 parent 524442f commit 904b05b0d31c707a7ecee8ca55c43a491d26439d
Showing with 3 additions and 1 deletion.
  1. +3 −1 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);

0 comments on commit 904b05b

Please sign in to comment.
You can’t perform that action at this time.