Math related scriping question

I have an inventory item with a stack of 9 and a max stack of 10. I pick up an item of 4. I add 9 + 4 for 13, then subtract it by the max stack 10. This gives me an amountOverMax of 3.

I think you just check if the stack amount to be is greater than the max stack size before you do anything.

So then it’s just currentQty + addQty - maxStackSize, which you can then subtract off the addQty.

So 9 + 4 - 10 == 3 => 4 - 3 == 1.

Editing your posts like this is against the rules. Even if you figured out your problem someone might find this thread useful in the future.

I changed the thread back to the original.

This answer is exactly correct. Thank you.