Jump to content

[LE] Help with Script.


Recommended Posts

ScriptName TestScriptAgain Extends Actor



Keyword Property MagicDamageFire Auto


Int MagicFXnum = Spell.GetNumEffects()

Error: no viable alternative at input "Spell"

Error: required (...)+ loop did not match anything at input "."

Error: Unknown user flag Spell


Int Index = 0


Event OnObjectEquipped(form akBaseObject, ObjectReference akReference)


While index < MagicFXnum


MagicEffect MagicFX = spell.GetNthEffectMagicEffect(index)


If MagicFX.HasEffectKeyword(MagicDamageFire)


Debug.MessageBox("Fire Spell")


Else Index += 1

Error: Required (...)+ loop did not match anything at input "index"


EndIf


EndWhile


EndEvent



What am i doing wrong?

...apart from trying to mod this damn game :laugh:

Link to comment
Share on other sites

You cannot define a variable with the result of a function outside of an event or function.

The variable "spell" is not defined. Papyrus has no idea what you want done there.

"Else" does not use parameters and is thus throwing off what you want to do with "index"

 

I am going to guess that you want to cycle through the magic effects on a given spell and return a message box if it has the specified magic effect. The following example (using your posted code as a base) shows how to do this with a spell as it is equipped by the player.

 

Please note that the following has not been tested for compilation or function:

ScriptName TestScriptAgain Extends Actor

Keyword Property MagicDamageFire Auto

Event OnObjectEquipped(form akBaseObject, ObjectReference akReference)
  If akBaseObject as Spell ; a spell was equipped
    Spell mySpell = (akBaseObject as Spell) ; assign equipped spell to local variable
    Int MagicFXnum = mySpell.GetNumEffects() ; get number of magic effects
    While MagicFXnum >= 0
      MagicEffect MagicFX = mySpell.GetNthEffectMagicEffect(MagicFXnum) ; get magic effect
      If MagicFX.HasEffectKeyword(MagicDamageFire) ; does magic effect have desired keyword
        ; it does, display message and get out of loop
        MagicFXnum = -1
        Debug.MessageBox("Fire Spell")
      Else
        ; it does not, check next magic effect
        MagicFXnum -= 1
      EndIf
    EndWhile
  EndIf
EndEvent 

 

 

Link to comment
Share on other sites

  • Recently Browsing   0 members

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