Jump to content

Recommended Posts

Posted (edited)

For some reason this script runs BOTH If statements??

Scriptname AAAGiveSpells extends activemagiceffect  

SPELL Property HolyLight  Auto
BOOL  Property HolyLightKnown = False Auto


Event OnEffectStart(Actor akTarget, Actor akCaster)

Actor Player = Game.GetPlayer()
INT PlayerLevel = Player.GetLevel()

;HOLY LIGHT

If PlayerLevel >= 1 && HolyLightKnown == false
	Player.addspell(HolyLight)
	Debug.Messagebox("Holy Light Added")
        HolyLightKnown = true
EndIf


If PlayerLevel >= 1 && HolyLightKnown == true
	Debug.Messagebox("You already know this spell.")
EndIf



EndEvent
Edited by gitsas
Posted

Multiple ways to fix this.

Examples:

  Reveal hidden contents

 

Posted (edited)
  On 3/12/2021 at 1:07 PM, IsharaMeradin said:

Multiple ways to fix this.

Examples:

  Reveal hidden contents

 

 

Thank you so much! it works!

 

I also tried to add an animation:

elseif Player.HasSpell(HolyLight) && PlayerLevel >= 1
	Game.ForceThirdPerson()
	Debug.SendAnimationEvent(Player, "IdlePray")
	Utility.Wait(4.0)
	Debug.Messagebox("You now know Holy Light.")

Everything works great, but the animation never stops.

Do you by any chance know how I can stop it?

 

I tried:

Debug.SendAnimationEvent(Player, "ActionIdleStop")

But it doesn't work.

 

Thanks again for the help!!

Edited by gitsas
Posted (edited)
;------------------------------------ why it didn't work
If PlayerLevel >= 1 && HolyLightKnown == false ; they don't have the spell and are over level 0
Player.addspell(HolyLight) ; spell added
Debug.Messagebox("Holy Light Added") ; added announced
HolyLightKnown = true ; flag set to true
EndIf
; at this point in the script they now have the spell and the flag is set to true so the next if statement will fire too
If PlayerLevel >= 1 && HolyLightKnown == true ; they do have the spell and are over level 0
Debug.Messagebox("You already know this spell.") ; known announced
EndIf

;------------------------------------ fix (one of many ways)

 

If HolyLightKnown == true ;most unlikely checked 1st
Debug.Messagebox("You already know this spell.")
Elseif PlayerLevel >= 1 ; fix with a double meaning (no need for the &&) elseif statement
Player.addspell(HolyLight)
Debug.Messagebox("Holy Light Added")
HolyLightKnown = true
EndIf
I also find the >= level 1 suspect ... is it possible to be a level 0 ?
Edited by NexusComa2
Posted
  On 3/13/2021 at 9:30 AM, NexusComa2 said:

 

I also find the >= level 1 suspect ... is it possible to be a level 0 ?

 

Not possible to be level 0. The player always starts out at level 1.

Posted

I didn't think so and would make that part of the script redundant. So ...

 

if HolyLightKnown == true ;most unlikely checked 1st

Debug.Messagebox("You already know this spell.")
Else ;simple else statement
Player.addspell(HolyLight)
Debug.Messagebox("Holy Light Added")
HolyLightKnown = true
EndIf
Posted

Unless they are testing the script to ensure that it behaves properly before adding in the correct level requirement. In which case, the level check would still need to be present.

Posted

True. The only real issue was "syntax logic". The "old true/false", if statement logic error in with the syntax. Just looking for a way to slip in how an else statement would be used ...

The combinations of: if, else, elseif and endif can be used to ask any question or direct program flow and logic. Well worth the time to really dig into how the combinations can be used (along with, used with flags).

I just looked at your [ Spoiler ] ... I see you did cover that ...

  • Recently Browsing   0 members

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