RegisterForUpdateGameTime in cleanup script

Post » Sat Nov 17, 2012 8:45 pm

I have a script setup to clean up an actor after they are dead... Basically it deletes them...
My question is should the UnregisterForUpdateGameTime come after the self.delete on the actor script or before ? Does it matter ?

Thanks
User avatar
Amanda Furtado
 
Posts: 3454
Joined: Fri Dec 15, 2006 4:22 pm

Post » Sat Nov 17, 2012 9:31 am

My understanding is that if delete doesn't free up the memory used by the object, then nothing else will either, so it's pointless (but my understanding is often wrong, so don't believe a word I say!)

There's a topic somewhere on here (last week or so) discussing persistence ... linked to a few wiki articles about the same thing ... My memory of that is that it is all too easy to make something persist; and once you have, there's no getting back from there.


All that said, you would have to Unregister before you delete ... or there is nothing to unregister ... but, as I said, might well not make any difference if you don't run the "clean up" at all (and again, often I have no idea what I am typing! ;))
User avatar
Manuel rivera
 
Posts: 3395
Joined: Mon Sep 10, 2007 4:12 pm

Post » Sat Nov 17, 2012 8:46 pm

you should unregister as the first line in the update block

regarding persistence, if the actor is referenced as an Actor Property ANYWHERE (including conditions in dialogue topics, magic effect conditions, etc), or is currently filling an alias, it will likely be permanently persistent and deleting will either not even execute, or will have absolutely no effect and pointless.

if the actor was ForceRef'd into an optional alias, clearing that alias will release its persistence, and can be safely deleted. same goes for any script that uses an empty Actor or ObjectReference Property/variable and is filled dynamically by assigning it to the NPC at runtime. If this variable/property is cleared (set to a none value or filled with a different value) and the function in the script that uses it has COMPLETELY finished running (this includes all registered events), the actor's persistence is cleared. if you explicitly declare an Actor property and fill it with a specific actor in the CK, there is nothing in the world that will ever release its persistence (except for uninstalling the mod)

another faux pas to watch out for is "dirty editing" your own mod. this can happen even if your mod has no vanilla edits whatsoever, and your actor was entirely created in your own esp.

if you declare an actor as a Actor property or specifically referenced in a condition/alias etc, that actor's reference object is permanently flagged as persistent in the esp itself. even if you delete the condition function, and unfill and delete the script property etc. nothing short of reloading a previously saved version of your plugin or deleting the reference entirely will release the persistence flag on the reference object (reaaaaaaaaaallllllllly effing annoying).
User avatar
i grind hard
 
Posts: 3463
Joined: Sat Aug 18, 2007 2:58 am


Return to V - Skyrim