Modding Best Practices and Changes Persisting in Saved Games

Post » Sun Jun 24, 2012 7:55 am

First of all I'd like to ask if the community has compiled a list of best practices for new modders to follow somewhere? If not perhaps we should create one and see if a mod could sticky it. I believe this would be an important resource for the community and something that could save us newer modders from some uneeded headaches. I personally always appreciate the wisdom of those more experienced than myself.

Secondly, from doing some reading I've learned that certain changes mods make can persist in the save game after the mod has been removed. Thus, certain mods may need special procedures for uninstalling or updating to newer versions. As a mod creator what kinds of changes can persist in this fashion and are there any general rules of thumb for undoing changes on removal of the mod by the player? Basically, how do I know if I'm going to need my users to go through a special process for either updating the mod to a newer version or removing the mod? Honestly, this may fall in with best practices as well.
User avatar
Nuno Castro
 
Posts: 3414
Joined: Sat Oct 13, 2007 1:40 am

Post » Sun Jun 24, 2012 4:37 am

NEVER change the mod file(s) name (.esm or esp file) after every update or fequently. If you really got to change the name then (atleast) give a 3 day notice.
User avatar
Gen Daley
 
Posts: 3315
Joined: Sat Jul 08, 2006 3:36 pm

Post » Sun Jun 24, 2012 3:33 am

Do not add a script that continually updates without unregistering the update.
Updatting script data persists in a save even if you remove the mod and script that started it.
(Though this may have changed with one of the recent updates to Skyrim, not sure.)

Make it a point to use registerforsingleupdate instead of registerforupdate.
Then at the end of your event block call another registerforsingleupdate but make it conditional (inside an if / endif).
User avatar
Quick Draw III
 
Posts: 3372
Joined: Sat Oct 20, 2007 6:27 am

Post » Sun Jun 24, 2012 12:08 pm

Take a look at this thread for scripting related stuff: http://www.gamesas.com/topic/1359724-on-the-run-time-of-skyrims-papyrus-scripts/
User avatar
Pete Schmitzer
 
Posts: 3387
Joined: Fri Sep 14, 2007 8:20 am

Post » Sun Jun 24, 2012 3:26 am

My two cents, from personal experience...

Avoid the use of Global Variables when possible. Use script properties instead. Global Vars can linger in a save game long after the mod that they belonged to are gone. They can also cause some rather erratic script behavior when the plugin they belong to is updated, because multiple copies of the same GlobalVariable may be created at runtime.

Example:

myGlobalVariable.SetValue(100)if myGlobalVariable.GetValueInt() == 0    Game.GetPlayer().Kill()endif

In the above example, you may end up inadvertently killing the player as soon as this script block is run if you update your plugin file. The reason is because the duplicate, unused myGlobalVariable will initialize to 0 (not null), and your script will still catch it. It's almost as if the papyrus script engine uses an implicit OR when evaluating whether or not a condition involving a Global Variable is true; if any of the duplicate Global Variables match the given condition, it will return true.

If you must use Global Variables, and need to simulate a boolean condition, use 1 and 2, not 0 and 1; that way, duplicate Global Variables that initialize to 0 will be ignored by the condition if you update your plugin.
User avatar
Kara Payne
 
Posts: 3415
Joined: Thu Oct 26, 2006 12:47 am


Return to V - Skyrim