Editing OnItemRemoved - ObjectReference
Jump to navigation
Jump to search
Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.
The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then publish the changes below to finish undoing the edit.
Latest revision | Your text | ||
Line 35: | Line 35: | ||
**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. | **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. | ||
* If player uses a poison to apply it to a weapon the event is fired twice: before and after the confirmation dialogue. If canceled in the confirmation dialogue then is not fired twice. | * If player uses a poison to apply it to a weapon the event is fired twice: before and after the confirmation dialogue. If canceled in the confirmation dialogue then is not fired twice. | ||
*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 OnItemRemoved 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 OnItemRemoved won't stop Skyrim from dumping stacks when something calls RemoveAllItems(), because the first OnItemRemoved call only executes after the other hundred or so have been queued. You'd have to stop listening to inventory events before the item removals ever take place. | **This trick stops OnItemRemoved 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 OnItemRemoved won't stop Skyrim from dumping stacks when something calls RemoveAllItems(), because the first OnItemRemoved call only executes after the other hundred or so have been queued. You'd have to stop listening to inventory events before the item removals ever take place. | ||
== See Also == | == See Also == |