Editing Papyrus FAQs

Jump to navigation Jump to search

Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.

The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then publish the changes below to finish undoing the edit.

Latest revision Your text
Line 235: Line 235:


=== How do I write save-safe scripts then? ===
=== How do I write save-safe scripts then? ===
According to SmkViper:
<pre>
Removing mods and continuing with a save that relies on that mod is not and
never has been supported. Proceed at your own risk. Demons may fly out of your
monitor and spray you with silly string. (You think I'm kidding - have you heard
of Bob the modder? No? Exactly.)
</pre>
However, here are some evolving guidelines that can be followed to reduce the incidence of uninstallation issues and/or shift the blame to user error:
# Instead of using a <code>While</code> loop, use an <code>OnTimer()</code> event. The <code>OnTimer()</code> event is Fallout 4's version of Skyrim's <code>OnUpdate()</code>. Refer to the question and answer below for more information.
# Avoid endless <code>While</code> loops that cannot terminate after the plugin has been removed. For example, a <code>While Player.HasPerk(kPerk)</code> loop can terminate if <code>kPerk</code> references a perk unique to the plugin. Removing the plugin removes the perk, and so when the player loads a save, the thread can then exit. However, if <code>kPerk</code> references a vanilla perk, <code>HasPerk()</code> will always evaluate to <code>True</code> and the <code>While</code> loop will continue iterating over instructions that may require objects which no longer exist, and therefore keep the thread alive, consuming memory, contributing to script lag, and producing errors. Refer to the above question for more information about how <code>While</code> loops and saves interact.
# Always finish your code as fast as possible. This ultimately means making optimizations to both your scripts and your systems. For example, if you need a <code>While</code> loop to iterate through a large formlist or array, chunk the formlist or array, and in between each chunk, give the loop an opportunity to exit. You might also want to ensure that there are enough conditions in place that your script can run only when needed, do its job, and get out when the job's done.
# Provide the user with the ability to "uninstall" your mod while in the game. This can be done by offering users a "Shutdown" option in a holotape menu that forcibly exits all continuously running scripts. Some users may not take the time to take advantage of this feature, so it remains important to ensure that you've taken the necessary steps to write save-safe scripts.
# Finally, warn users that uninstalling mods and continuing with saves that rely on those mods is unsupported and unsafe.
=== How would I emulate a Break statement in a While loop? ===
=== How would I emulate a Break statement in a While loop? ===


Please note that all contributions to the Fallout4 CreationKit Wiki are considered to be released under the Creative Commons Attribution-ShareAlike (see FalloutCK:Copyrights for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource. Do not submit copyrighted work without permission!

Cancel Editing help (opens in new window)