51offthescale Posted August 15, 2023 Posted August 15, 2023 (edited) If I have a magic effect with a script that calls RegisterForSingleUpdate(), but that magic effect is then dispelled before OnUpdate() is called, does the script still have something registered and not cleared down? I ask because I have a "failsafe" where the magic effect is dispelled but I believe this may be redundant as I am only calling updates in a single chain like so: Event OnUpdate() if(condition) runSomething() RegisterForSingleUpdate() else UnRegisterForUpdate() endif endEvent Edited August 15, 2023 by 51offthescale typo
DarkBlade13 Posted August 15, 2023 Posted August 15, 2023 (edited) First of all I have no idea if the script is still firing after the spell stopped. I don't think it will but you should probably test it. Just do like this Event OnUpdate() Debug.Notification("Yep it's still running") if(condition) runSomething() RegisterForSingleUpdate() else endif endEvent You can tell if it did. Secondly you don't need an UnregisterForUpdate(). You can just remove that part and leave the Else part empty. If your script is using a RegisterForSingleUpdate(). That means it only fires once. Unregister is for the RegisterForUpdate(10.0) function. With this function you would have an update firing every 10 seconds. Then you need and UnregisterForUpdate() to stop. Edited August 15, 2023 by DarkBlade13 1
51offthescale Posted August 15, 2023 Author Posted August 15, 2023 (edited) Ah of course the UnRegisterForUpdate() is also redundant. I'll try out adding the notification and see if anything fires after the dispel. Thanks for the help. Edited August 15, 2023 by 51offthescale 1
DarkBlade13 Posted August 15, 2023 Posted August 15, 2023 Not sure if you aware of it but you do realise you need to RegisterForUpdate first before you have the Event OnUpdate right? Function SomeFunction() RegisterForSingleUpdate() ; Before we can use OnUpdate() we must register. EndFunction Event OnUpdate() ; This event occurs every five seconds If myQuest.GetStage() == 10 Debug.Trace("My quest is now on stage 10!") EndIf EndEvent
51offthescale Posted August 16, 2023 Author Posted August 16, 2023 Yup I have an Event OnEffectStart which calls RegisterForSingleUpdate first 1
51offthescale Posted August 16, 2023 Author Posted August 16, 2023 To answer my own question, I don't think that dispelling the magic effect after calling RegisterForSingleUpdate and before OnUpdate is called leaves anything from magic effect script. A message added to OnUpdate wasn't printed when the magic effect was dispelled. I also span up several magic effects which were then dispelled and then checked my save with ReSaver which didn't show anything related to the scripts I was running.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now