aboutsummaryrefslogtreecommitdiff
path: root/src/script/lua_api/l_item.cpp
diff options
context:
space:
mode:
authorPaul Ouellette <oue.paul18@gmail.com>2019-10-23 13:48:19 -0400
committerSmallJoker <SmallJoker@users.noreply.github.com>2019-10-23 19:48:19 +0200
commit904b05b0d31c707a7ecee8ca55c43a491d26439d (patch)
treed9ada46f4b079bce900dd846f36bd5ded41760ec /src/script/lua_api/l_item.cpp
parent524442fc5e9bc64952301b9ba25aefb0d9bf781b (diff)
downloadminetest-904b05b0d31c707a7ecee8ca55c43a491d26439d.tar.gz
minetest-904b05b0d31c707a7ecee8ca55c43a491d26439d.tar.bz2
minetest-904b05b0d31c707a7ecee8ca55c43a491d26439d.zip
Allow calling ItemStack with no arguments (#8783)
Diffstat (limited to 'src/script/lua_api/l_item.cpp')
-rw-r--r--src/script/lua_api/l_item.cpp4
1 files changed, 3 insertions, 1 deletions
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);