mirror of
https://github.com/minetest/minetest.git
synced 2024-12-25 15:42:24 +01:00
Allow calling ItemStack with no arguments (#8783)
This commit is contained in:
parent
524442fc5e
commit
904b05b0d3
@ -414,7 +414,9 @@ ItemStack& LuaItemStack::getItem()
|
|||||||
int LuaItemStack::create_object(lua_State *L)
|
int LuaItemStack::create_object(lua_State *L)
|
||||||
{
|
{
|
||||||
NO_MAP_LOCK_REQUIRED;
|
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);
|
LuaItemStack *o = new LuaItemStack(item);
|
||||||
*(void **)(lua_newuserdata(L, sizeof(void *))) = o;
|
*(void **)(lua_newuserdata(L, sizeof(void *))) = o;
|
||||||
luaL_getmetatable(L, className);
|
luaL_getmetatable(L, className);
|
||||||
|
Loading…
Reference in New Issue
Block a user