OnDetachItemMod
A function added by the pp NVSE Plugin.
Contents
Description
Sets/removes the specified UDF Script as a handler that will be invoked when an item mod is detached from another object through the extended mods system. The script is passed two arguments, the item mod that was detached, and the instance of the object.
- Filter 1 is the item mod
- Filter 2 is the object the item mod is being detached from.
Syntax
OnDetachItemMod priority:int script:ref runOnDeconstruct:bool filter1:filter filter2:filter
Example
OnDetachItemMod 1 OnDetachScript 1 "1" itemMod "2" WeapNV9mmPistol
Sets the OnDetachScript script as a handler with 2 filters. OnDetachScript will run when itemMod is attached to WeapNV9mmPistol
OnDetachItemMod OnDetachScript 0
Removes the OnDetachScript script as a handler.
OnDetachItemMod OnDetachScript 1 OnDetachScript 1 "2" WeaponBaseForm
Sets the OnDetachScript script as a handler with 1 filter.
Handler Script
scn OnDetachScript
ref rItemMod
ref rWeap
begin Function {rItemMod, rWeap}
;code
end
Devkit usage
This function works on Weapon Forms, as well as Item mod forms.
Devkit Syntax
OnAttachItemMod int:priority ref::script bool::runOnDeconstruct filter::WhenDetachedFrom
Example
Link: MySilencerAttachment {
Name: Silencer Mod
OnDetachItemMod: 1 MyUDF 1 WeapNV9mmPistol
}
Will call MyUDF anytime MySilencerAttachment is detached from WeapNV9mmPistol.
Link: MySilencerAttachment {
Name: Silencer Mod
OnDetachItemMod: 1 MyUDF
}
Will call MyUDF anytime MySilencerAttachment is detached from any object.
Notes
- this function also works in kit.
- runOnDeconstruct should almost always be enabled. Having this enabled will cause your script to run every time the object instances are recycled on load, or destroyed. There are some edge cases where you might not want this to take place. See SetOnInstanceDeconstruct