Jump to content

Scripts runs after uninstallation and clean save


PixelMurder

Recommended Posts

Hi, folks,

to make a video from mod start, i have created a clean save.

After, for any reason i loaded the game without mod and what did i see?

The quest script runs without mod, without quest and without script and shows all 6 seconds this message. DebugState was previously for development reasons set to true.

 

;(simplified)
bool Property DebugState = false  Auto
Event OnUpdate
   If (DebugState)
     Debug.Notification("XXX")
  EndIf
 ; Do something...
EndEvent

 

Even, after a new clean save and game restart, the script continues to run.

 

Then i have inserted a new line in my code:

Event OnInit
  DebugState = false
  Game.GetPlayer().AddSpell(DRWFxMagicSpell, true)
EndEvent

 

But even after activation of the mod and after i received the spell, all 6 seconds, the message appeared.

 

I had to comment out the notfication, because this was the only method to remove it.
   If (DebugState)
     ; Debug.Notification("XXX")
  EndIf

 

From on step to other, i have deleted bsas and unchecked in NMM. The scripts i have recompiled and leaved it in the scripts folder.

 

This takes me to the conclusion, that:

-scripts are saved in save games, even if no esp and no mod data exists

-on update, even with a clean save, only parts of the script lines are refreshed

 

I think, this is a big fat bug. Scripts and their events have to be unloaded instantly, if a mod and its parent object doesn't exist anymore. And if you update any mod, all script functions have to be refreshed.

 

Have anybody noticed the same thing and what do you think about it?

 

Cheers

PixelMurder

(sorry, for my bad english)

Link to comment
Share on other sites

Thank you for the answer and link :-)

 

Okay, variable values on update is one thing, there has to be rules and i will learn them.

Leaving a quest-event-block from a removed mod running, is simply bull**** of programmer noobs, sorry. Maybe this comes from the same people, who can't set a 4GB-flag, or can't compile and optimise an exe and leaved us with 100% less performance, until the whole web names them "idiots".

I have good reasons to run OnUpdate every 6 seconds from start to the end of the game. But imagine you play 200 hours, installing and rermoving several mods and seven of them has expensive OnUpdate-Blocks, this will slow down Skyrim even on the best machines.

Link to comment
Share on other sites

I use unregister, when i don't need updates. But all the reactions of my mod depends heavy on this updates.

 

Hmm, is there any way to check, when a save is loaded or if a given mod exists?

 

This is a serious thing for me. I don't like, if people are uninstalling my mod, but i can't leave them with shitty event blocks running, slowing down their game.

 

I have to configure, how i can stop events, when the mod is not loaded, maybe there is any hack for this. Logically, i don't want to create an uninstaller, to clean saves from my mod.

Link to comment
Share on other sites

I wonder if your OnUpdate script could do something like (pseudo code)

EVENT OnUpdate
 if this.AlreadyRunMyFancyScript == 0
   if player.addspell(myfancyspell) then 
     modinstalled = 1
   else 
     modinstalled = 0
   endif
   this.AlreadyRunMyFancyScript = 1
 
   if modinstalled == 0
     unregisterforupdates()
   endif
 else
   this.runOnUpdateScript()
 endif
endEVENT

 

This is supposed to check whether your mod is installed by seeing if something it adds is still available... and rather than making this check everytime, we just do it once (maybe once per cell load by resetting the AlreadyRunMyFancyScript in the onCellLoad)

Link to comment
Share on other sites

For background running scripts, use RegisterforSingleUpdate() and re-register every time the script ticks - that will kill it if you uninstall the mod, after it does one more cycle.

Alternatively, you can script an uninstall/reset script which basically flips an internal boolean switch, which is checked by the main script. If the switch is "off", then the main script unregisters itself and that will also kill it. In that case you can use RegisterForUpdate() in the usual fashion to initialize the main script. You can also flip the switch back to "on" state as a part of your init function for the main script, which enables the mod to be reinstalled.

Link to comment
Share on other sites

I think, that i have found a solution and this also to check, if there was a previous version installed.

 

int Property FxVersion Auto
GlobalVariable Property DRWFxVersion Auto
bool lockFunctions = false ; Variable to lock functions

Event OnInit ()
   FxVersion = 15 ; Starts with 1,  Increment this for any version
   DRWFxVersion.SetValueInt(FxVersion)
EndEvent

Event OnUpdate()
If (DRWFxVersion.GetValueInt() == 0) ; Global doesn't exist = mod doesn't exist
     UnregisterForUpdate() 
ElseIf (DRWFxVersion.GetValueInt() != 15) ; Not the same value as in OnInit()  =  not the same version
                  DRWFxVersion.SetValueInt(15) ;
ElseIf (DRWFxVersion.GetValueInt() == 14) ; Not the same value as in OnInit() , but no reaction needed
                 DRWFxVersion.SetValueInt(15)
ElseIf (DRWFxVersion.GetValueInt() == 13) ; Not the same value as in OnInit() , reaction needed
                  DRWFxVersion.SetValueInt(15)
                  MsgPleaseStartWithCleanSaveBecauseThisEngineIsFromHell.Show()
                  DoSomething()
             Else
                  DoUpdateFunctions()
EndIf
EndEvent

 

Maybe, i can improve this.

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...