Force a ReferenceAlias to run a script on quest restart?

Post » Sun Nov 02, 2014 5:52 pm

My mod has an uninstall and reinstall feature that lets you prepare it for uninstall, update the mod, and then reinstall it - with no need to actually remove the mod from your load order, load your game and remove its objects, then reinstall the mod and load your game again.

Current problem:
It requires a quest with a ReferenceAlias on the player character. The "prepare for uninstall" utility clears the ReferenceAlias, and the reinstall script restarts the quest. However, the ReferenceAlias script either isn't starting or its event handlers aren't being set up.

Here's the reinstall quest starting script segment:

Alias.ForceRefIfEmpty(Player)
Quest.start()
Quest.reset()

When I check the quest alias in the conole using the ShowQuestAliases command, everything looks normal, and the quest is also running, but the ReferenceAlias script has no effect.

How do I force a ReferenceAlias to run a script?
User avatar
Emmi Coolahan
 
Posts: 3335
Joined: Wed Jan 24, 2007 9:14 pm

Post » Sun Nov 02, 2014 9:21 am

What part of the script isn't working? Are you using Stop() on the quest after you remove the player from the alias? The reference alias script might not ever stop unless you explicitly force the quest to stop too.

User avatar
willow
 
Posts: 3414
Joined: Wed Jul 26, 2006 9:43 pm

Post » Sun Nov 02, 2014 3:32 pm

The uninstall script just stops the quest (uses the Stop() function). This appears to clear the ReferenceAlias. There's no problem with stopping the reference alias script - I can confirm that it stopped, actually.

I'm looking for instructions on how to get it running properly on a restart. In particular, the restart should act as if the mod was just installed and the quest script was freshly installed.
User avatar
Alexander Lee
 
Posts: 3481
Joined: Sun Nov 04, 2007 9:30 pm

Post » Sun Nov 02, 2014 7:45 am

That doesn't happen in Skyrim. No matter what you do the Properties you had in the script for the first version will never get any changed values you might make in the CK for the second version. Stopping and restarting the quest should cause the script's OnInit and other events to fire again, but I suspect that the OnInit for alias scripts will only fire one time. The scripts don't ever truly stop, but when the aliases get cleared when the quest stops it prevents any events from being triggered.

Just forcing the reference to the player while the quest is running should be enough to make standard events fire, but if you're depending on OnInit you're going to have to rethink your strategy.
User avatar
Farrah Lee
 
Posts: 3488
Joined: Fri Aug 17, 2007 10:32 pm


Return to V - Skyrim