I am trying to make a simple toggle for magic effects. I am trying to make the effect dispel when I press a button. I can get the script to compile. However, ingame, the magic effect is immediately dispelled instead of when a button is pressed for a second time.
Here is what I have so far.
Scriptname CoreyOnActorAction extends activemagiceffect
MagicEffect Property Effect auto
 
Event OnInit()
If Game.GetPlayer().HasMagicEffect(Effect)
Dispel()
Debug.MessageBox("Effect Off")
Else
Debug.Notification("Effect On")
EndIf
EndEvent
Any help would be greatly appreciated.
Edit***
Figured it out: It was very difficult. It seemed so easy at first. The way I was doing it at first would activate the effect and then immediately disable. Not really a toggle that I was looking for. To make the toggle work, I needed a script. The only script that I could use would be scripts to add and remove a spell. I couldn’t find a script on the Wiki that would add an effect.
So I needed 2 magic effects and 2 spells. The second effect/spell would add the first with a script.
1. Create desired magic effect and set it be CONSTANT under CASTING TYPE.
2. Create a spell, add first created magic effect to effects list and set it to ABILITY under TYPE.
3. Create another magic effect. Set EFFECT ARCHETYPE to SCRIPT
4. Create another spell. Add the second created effect to the effects list.
*****************************************************************************
Add this script to the second created magic effect:
*****************************************************************************
Scriptname YourScriptName extends activemagiceffect
Spell Property YourSpell auto
Event OnEffectStart(Actor Target, Actor Caster)
If(Target.HasSpell(YourSpell))
IF Target.RemoveSpell(YourSpell)
;Debug.Notification("Effect Off")
;{Testing purposes to see if it is working.}
EndIf
Else
Target.AddSpell(YourSpell)
;Debug.Notification("Effect On")
;{Testing purposes to see if it is working.}
EndIf
EndEvent