Tutorial: String Variables 4
This is the fourth article in a tutorial series on string variables.
Destroying String Variables
NOTE: with xNVSE, string_vars get automatically cleaned up once a UDF stops running.
- Mod authors should however continue using Sv_Destruct to prevent save bloating for people using older versions of NVSE.
With regular vanilla script variables (ref float int short long), you don't need to worry about them after you've used them. If you stuck them in a quest script, you meant to keep them around indefinitely until your mod's uninstalled; if they're part of an object or spell script that doesn't run anymore, they simply disappear from view - you don't need to erase them.
It's different with string variables, whose strings keep lingering in the .nvse files even if the script they were in doesn't run anymore. They are forcibly removed when your mod is uninstalled, but in the meantime they cause a bit of bloat, so be sure to remove/uninitialize/destroy them yourself as soon as you don't need them anymore by doing
sv_destruct MyStringVar
You can destroy up to 10 different ones in the same line like that:
sv_destruct stringvar1 stringvar2 stringvar3 stringvar4 stringvar5 stringvar6 stringvar7 stringvar8 stringvar9 stringvar10
String vars are also the only UDF local variables that you need to destruct yourself.
Tutorial part 5: Checking String Variables