Jump to content

Dispel magic effect that calls RegisterForSingleUpdate


Recommended Posts

Posted (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 by 51offthescale
typo
Posted (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 by DarkBlade13
Posted (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 by 51offthescale
Posted

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

 

Posted

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.

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

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