Difference between revisions of "OnItemRemoved - ObjectReference"

Jump to navigation Jump to search
→‎Notes: I just tested Diplomatic Immunity with a mod that makes this mistake. On my normal savegame, carrying my usual amount of items, that mod caused stack dumping, generating at least 118 stacks (those were the ones that got dumped). So yeah.
imported>DavidJCobb
imported>DavidJCobb
(→‎Notes: I just tested Diplomatic Immunity with a mod that makes this mistake. On my normal savegame, carrying my usual amount of items, that mod caused stack dumping, generating at least 118 stacks (those were the ones that got dumped). So yeah.)
Line 33: Line 33:
*If you only care about certain kinds of objects, you should also use [[AddInventoryEventFilter - ObjectReference|AddInventoryEventFilter]] to filter out any events for things you aren't interested in.
*If you only care about certain kinds of objects, you should also use [[AddInventoryEventFilter - ObjectReference|AddInventoryEventFilter]] to filter out any events for things you aren't interested in.
**Refer to the notes for [[OnItemAdded - ObjectReference#Notes|OnItemAdded]] to get an idea of how important this is.
**Refer to the notes for [[OnItemAdded - ObjectReference#Notes|OnItemAdded]] to get an idea of how important this is.
**If something calls [[RemoveAllItems - ObjectReference|RemoveAllItems]] and you don't use an inventory event filter, then for every type of item removed from the object's inventory, one call to your OnItemRemoved event handler will be queued. If the player is holding a very wide variety of items (like alchemy ingredients and books in addition to the player's usual gear), then Skyrim may queue up more calls than it can even keep track of, causing an instant stack dump.
**If something calls [[RemoveAllItems - ObjectReference|RemoveAllItems]] and you don't use an inventory event filter, then for every type of item removed from the object's inventory, one call to your OnItemRemoved event handler will be queued. If the player is holding a wide variety of items, then Skyrim will queue up more calls than it can even keep track of, causing an instant stack dump. This may negatively impact your own script as well as other scripts written by other people.
***The "Diplomatic Immunity" quest is a good testcase for this; getting thrown in jail may also work.
***The "Diplomatic Immunity" quest is a good testcase for this; getting thrown in jail may also work.
*If the item is consumed by any means (crafting, charging, poisoning, eat/drink) the dest parameter is None and most likely, but not always, the reference is None too.
*If the item is consumed by any means (crafting, charging, poisoning, eat/drink) the dest parameter is None and most likely, but not always, the reference is None too.
Anonymous user

Navigation menu