Jump to content

Inventory:GiveItem can generate garbage at 000


Littlefat1213
  • Pending
function Inventory:GiveItem(inst, slot, src_pos)
  ......
  	else	-- should consider the case that stacksize can exceed the maxsize after the stack combination
        if self.activeitem and self.activeitem ~= inst and
            self.activeitem.components.stackable and
            inst.components.stackable and
            self.activeitem.prefab == inst.prefab and
            self.activeitem.skinname == inst.skinname and
            not self.activeitem.components.stackable:IsFull()
            then
            self.activeitem.components.stackable:Put(inst, Vector3(self.inst.Transform:GetWorldPosition()))
            self.inst:PushEvent("gotnewitem", { item = inst, toactiveitem = true, })
            returnvalue = true
            shouldwisecrack = false
        else
            self:DropItem(inst, true, true)
        end
    end
  
end

First, keep your inventory full and make sure the active item in your inventory is stackable and not Full (for example twigs with 39 stacksize), After given the item that could exceeds the max stacksize (for example twigs with 2 stacksize), the leftover still at the previous position (could be 0,0,0 if it spawned without set world position) and won't be drop by your side.

In that case, stackable:Put try to combine the 39 and 2 stacksize but actually process 1 and leave 1 free.


Steps to Reproduce

As Above




User Feedback


There are no comments to display.



Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
  • Create New...