mirror of
https://github.com/luanti-org/luanti.git
synced 2025-10-21 11:55:43 +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();
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user