mirror of
https://github.com/luanti-org/luanti.git
synced 2025-10-22 04:15:44 +02:00
Update l_object.cpp
This commit is contained in:
@@ -326,30 +326,18 @@ int ObjectRef::l_add_item(lua_State *L)
|
|||||||
InventoryLocation loc = co->getInventoryLocation();
|
InventoryLocation loc = co->getInventoryLocation();
|
||||||
Inventory *inv = getServer(L)->getInventory(loc);
|
Inventory *inv = getServer(L)->getInventory(loc);
|
||||||
ItemStack item = read_item(L, 3, getServer(L));
|
ItemStack item = read_item(L, 3, getServer(L));
|
||||||
if (inv != NULL)
|
if (inv != NULL){
|
||||||
{
|
|
||||||
const char *listname = luaL_checkstring(L, 2);
|
const char *listname = luaL_checkstring(L, 2);
|
||||||
InventoryList *list = inv->getList(listname);
|
InventoryList *list = inv->getList(listname);
|
||||||
if(list)
|
if(list){
|
||||||
{
|
|
||||||
ItemStack leftover = list->addItem(item);
|
ItemStack leftover = list->addItem(item);
|
||||||
if(leftover.count != item.count)
|
if(leftover.count != item.count){
|
||||||
{
|
|
||||||
getServer(L)->setInventoryModified(loc);
|
getServer(L)->setInventoryModified(loc);
|
||||||
LuaItemStack::create(L, leftover);
|
LuaItemStack::create(L, leftover);
|
||||||
// Report inventory change to subscribed listeners
|
// Report inventory change to subscribed listeners
|
||||||
getServer(L)->getScriptIface()->on_inventory_add_item(loc, listname, item, leftover, co);
|
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);
|
LuaItemStack::create(L, item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user