Difference between revisions of "OnItemAdded - ObjectReference"

m
→‎Notes: The trick requires some finesse...
imported>DavidJCobb
(→‎Notes: Seriously do use AddInventoryEventFilter. Also, here's a good tip for stopping your event handlers temporarily (the only way to handle extreme cases).)
imported>DavidJCobb
m (→‎Notes: The trick requires some finesse...)
Line 35: Line 35:
**If the player takes a large number of items out of a container (e.g. by using the Take All feature while in their home), an OnItemAdded event handler that doesn't use an inventory filter will fire for each type (base form) of item that the player removes. If a container has a considerably large variety of items inside, too many OnItemAdded stack will accrue, causing Skyrim to dump those function calls as well as stacks from other mods/DLCs.
**If the player takes a large number of items out of a container (e.g. by using the Take All feature while in their home), an OnItemAdded event handler that doesn't use an inventory filter will fire for each type (base form) of item that the player removes. If a container has a considerably large variety of items inside, too many OnItemAdded stack will accrue, causing Skyrim to dump those function calls as well as stacks from other mods/DLCs.
*If you need to temporarily stop OnItemAdded and OnItemRemoved calls from being queued, you can use AddInventoryEventFilter with an empty FormList as an argument. To resume listening for item additions and removals, you can call [[RemoveAllInventoryEventFilters - ObjectReference|RemoveAllInventoryEventFilters]].
*If you need to temporarily stop OnItemAdded and OnItemRemoved calls from being queued, you can use AddInventoryEventFilter with an empty FormList as an argument. To resume listening for item additions and removals, you can call [[RemoveAllInventoryEventFilters - ObjectReference|RemoveAllInventoryEventFilters]].
**This trick stops OnItemAdded calls from ''being queued.'' It doesn't prevent the execution of function calls that have already been queued. To wit, using this trick from inside of OnItemAdded won't stop Skyrim from dumping stacks when you Take All from a QASmoke container. Rather, you'd want to stop listening to inventory events from elsewhere (e.g. an OnMenuOpen event checking for inventory menus, if you don't mind relying on SKSE).


== See Also ==
== See Also ==
Anonymous user