Papyrus scripts optimization questions

Post » Tue Feb 16, 2016 2:29 pm

Hi,



I have rather curious questions.



1. I noticed in some scripts people use "factions" instead of "globalvariables". This not only for booleans but also for small integer numbers mapped to factionrank. Why is that? Is getvalue and setvalue more demanding to the Papyrus VM than isinfaction and getfactionrank? Or is that just a philosophical thing?



2. I read that one should not use singleupdate even with rather longer times like registerforsingleupdate(10). Is that true? How can you replace this if you actually want to periodically have something run?

User avatar
Christine Pane
 
Posts: 3306
Joined: Mon Apr 23, 2007 2:14 am

Post » Tue Feb 16, 2016 1:06 pm

RegisterForUpdate() is dangerous when the mod with the OnUpdate() running, is removed. The OnUpdate() will never stop running and bloat the save as well as severely impact performance if the update intervals are very small. This can be prevented with proper use of UnregisterForUpdate(), however RegisterForSingleUpdate() is safer and preferred as it will only run OnUpdate() once. This only applies to RegisterForUpdate(). The other Register functions are fine.

User avatar
xxLindsAffec
 
Posts: 3604
Joined: Sun Jan 14, 2007 10:39 pm

Post » Tue Feb 16, 2016 7:35 am


I'm just guessing here, but maybe they are using factions in order to support an arbitrary number of NPCs? If one were to use global variables, then the number of NPCs that could be supported would be limited by the number of global variables one would have created (unless using a patcher to generate global variables).

User avatar
brian adkins
 
Posts: 3452
Joined: Mon Oct 01, 2007 8:51 am


Return to V - Skyrim