Morrowind Mod:SetDelete
< Mod / Morrowind: Morrowind Mod: Alphabetical Functions / Categorical FunctionsSetDelete
SetDelete, Flag Where: Flag = 1 to delete object, 0 to clear Type: Misc, Tribunal Returns: none Example: SetDelete, 1 Scripts: trapProjScript explosion_pushout
The SetDelete function can be used in combination with Disable to remove an object more completely. SetDelete 1 marks a reference for deletion while SetDelete, 0 clears that flag.
If the reference was placed in-game (e.g., by the player dropping an item, or by a PlaceAtPC script command), then it will be deleted immediately. But if the reference was placed by an esm or esp file, then it will be marked as deleted, and will not display nor have its scripts run. If you delete from the console you will notice this as in the title of the console: for an ingame reference, the title will revert back to "Console", while for an esp/esm reference the title will continue to match the reference id, and you will be able to setdelete 0, if you wish.
TipsEdit
Always disable the object at least one frame before deleting it. The main idea is to not delete the object while it is still actively engaged in some other activity.
Example code (near beginning of script):
if ( deleteobj = 1 ) ;Local variable, set when you want to delete if ( deletetimer == 0 ) Disable endif if ( deletetimer < 10 ) set deletetimer to ( deletetimer + 1 ) endif if ( deletetimer == 10 ) "my_object_01"->SetDelete, 1 endif Return endif
That way, with the return, it stops the rest of the script if it's up near the top of it (below where you set up the variables, though), and disables it, and gives it a bit of time before it's deleted. It may not need 10 frames, but that's not long, and it worked in my scripts. It can be quite a useful function in scripting things, as it allows for a script to use PlaceAtPC or PlaceItem scripts or such to create items within the world, at different locations, or different situations, where you may want to delete such items after.
Other useful tips for successfully using SetDelete are:
- Always disable the object at least one frame ahead of time.
- After entering a cell or using a cast spell or explode spell, wait two seconds before deleting.
- Always call setDelete from a local script.
- Never SetDelete if the object is in an inventory.
See Also: DontSaveObject