Rynas Posted February 9, 2018 Share Posted February 9, 2018 I'm not new to modding but haven't really paid much attention in the past to cleaning things up when uninstalled. I also haven't done much with quests. Generally, if a mod places custom objects in the world (either dynamically or by directly editing a cell), it seems that these objects will simply be removed if the mod is uninstalled. Is that right? Does this apply to quests? For example, if my mod adds MyQuest to the game and I save the game while the quest is active, when I uninstall the mod and reload the game, is the quest simply gone, along with any memory/resources devoting to tracking its stages, ReferenceAliases, etc.? If MyQuest has a script attached to it that is still running when I save the game, then I remove the mod and reload the game, will the script stop running, or will I constantly get logfile messages saying the game can't find the script's .pex file? If the MyQuest script periodically checks for things (using StartTimer() and Event OnTimer()), does ending the quest also stop the script? If MyQuest attaches scripts to some of its ReferenceAliases, do those scripts stop running automatically when the quest ends? If my mod spawns custom objects with scripts attached (like a light that turns on when actors are near it), do those scripts stop running when the mod is removed, since the objects they're attached to no longer exist? Basically, I'd like to figure out some "best practices" for mods that improve compatibility and clean up after themselves to avoid long-term problems. Link to comment Share on other sites More sharing options...
kitcat81 Posted February 9, 2018 Share Posted February 9, 2018 All items, quests and files will be removed together with the mod. Scripts will remain. Most events like OnActivate will not fire without physical objects, but remote and some other events will still do and can result in errors. An interesting thing that I can't explain is that if your scripts packed into .BA2, they will be removed after reload and won't produce errors in your log ...like if they never existed. But if you try to install the mod back with all the same scripts in your .BA2, you can start to get errors. With loose files (scripts) errors always remain unless you entirely delete the pex file from your Scripts folder.Some ways to avoid creating error spam:IsBoundGameObjectAvailable() function - checks if the script is still attached to any existing object (physical object , quest etc). Lets say you unistalled your mod and found out that some events (i.e. OnPlayerSleepStart) still fire in your QuestScript and result in errors. You can add this function to the event so the script runs this check before other functions. And you can use this check to send your script to inactive state.Example: ;Event MyEvent If IsBoundGameObjectAvailable() ;do some cool things else UnregisterForAllEvents() GoToState("EmptyState") EndEventNote, that it's not the same with magic effects. Magic effect script fails to find the bound object when the object is unloaded but will be able to find it again when the object gets loaded.Reference Alias scripts will stop running as soon as the alias gets cleared. They will automatically unregister for all events. Magic effect scripts will unregister for all events when the effect is expired.If you need frequent checks, it's better to use events instead of timers, of course when it's possible. Link to comment Share on other sites More sharing options...
Rynas Posted February 9, 2018 Author Share Posted February 9, 2018 Just the info I was looking for thanks! Link to comment Share on other sites More sharing options...
Recommended Posts