From ca6324a479a34c47f9b03db7c0fc338eeaa90ee4 Mon Sep 17 00:00:00 2001 From: Foghrye4 Date: Tue, 5 Apr 2016 15:22:17 +0400 Subject: [PATCH] Update l_object.cpp --- src/script/lua_api/l_object.cpp | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-) diff --git a/src/script/lua_api/l_object.cpp b/src/script/lua_api/l_object.cpp index 0672b5a4f..375ca4122 100644 --- a/src/script/lua_api/l_object.cpp +++ b/src/script/lua_api/l_object.cpp @@ -326,30 +326,18 @@ int ObjectRef::l_add_item(lua_State *L) InventoryLocation loc = co->getInventoryLocation(); Inventory *inv = getServer(L)->getInventory(loc); ItemStack item = read_item(L, 3, getServer(L)); - if (inv != NULL) - { + if (inv != NULL){ const char *listname = luaL_checkstring(L, 2); InventoryList *list = inv->getList(listname); - if(list) - { + if(list){ ItemStack leftover = list->addItem(item); - if(leftover.count != item.count) - { + if(leftover.count != item.count){ getServer(L)->setInventoryModified(loc); LuaItemStack::create(L, leftover); // Report inventory change to subscribed listeners getServer(L)->getScriptIface()->on_inventory_add_item(loc, listname, item, leftover, co); - // Get core.registered_on_inventory_update - //lua_getglobal(L, "core"); - //lua_getfield(L, -1, "registered_on_inventory_add_item"); - // Call callbacks - //InvRef::create(L, loc); // InvRef to 2 - //lua_pushstring(L, listname.c_str()); // listname 3 - //objectrefGetOrCreate(L, ref); // player 4 - //runCallbacks(9, RUN_CALLBACKS_MODE_LAST); } - else - { + else{ LuaItemStack::create(L, item); } }