Jump to content

[LE] Script wont compile


GSGlobe

Recommended Posts

I dont understand this error, what am I doing wrong here?

 

D:\Steam\steamapps\common\Skyrim Special Edition\Data\Scripts\Source\temp\Auto_Release_Combination_Script.psc(16,64): mismatched input ',' expecting RPAREN

D:\Steam\steamapps\common\Skyrim Special Edition\Data\Scripts\Source\temp\Auto_Release_Combination_Script.psc(16,67): required (...)+ loop did not match anything at input ')'

 

Not understanding this error, mismatched input . and +loop did not match anything at input

 

How to fix? LOL.. *crying* logic hurts my brain too much, I dont see it

 

Spoiler

Scriptname Auto_Release_Combination_Script extends activemagiceffect

 

Spell Property Auto_Store_Combination_Spell Auto

FormList Property Auto_Combination_FormList Auto

Spell Property AF_ReleaseBlastSPELL Auto

 

Event OnEffectStart(Actor akTarget, Actor akCaster)

 

Int nSize = Auto_Combination_FormList.GetSize()

If nSize != 0

int index = 0

While index < nSize

Spell TempSpell = Auto_Combination_FormList.GetAt(Index) as spell

If index == nSize - 1

(Auto_Combination_FormList.GetAt(0) as spell, 0).Cast(akTarget)

AF_ReleaseBlastSPELL.cast(akTarget)

else

(Auto_Combination_FormList.GetAt(Index + 1) as spell, 0).Cast(akTarget)

AF_ReleaseBlastSPELL.cast(akTarget)

EndIf

index +=1

EndWhile

EndIf

EndEvent

Link to comment
Share on other sites

Your problems are these lines:

 

(Auto_Combination_FormList.GetAt(0) as spell, 0).Cast(akTarget)

(Auto_Combination_FormList.GetAt(Index + 1) as spell, 0).Cast(akTarget)

 

The ", 0" shouldn't be there. You want:

 

(Auto_Combination_FormList.GetAt(0) as spell).Cast(akTarget)

(Auto_Combination_FormList.GetAt(Index + 1) as spell).Cast(akTarget)

 

When you see a 'mismatched input' compiler error, it means you've messed up your punctuation, basically. The three common ones (for me, anyway) are:

 

1. Using a single equals sign instead of a double equals sign in If statements;

2. Forgetting to close a parenthesis or string;

3. Forgetting to open a parenthesis or string.

Edited by foamyesque
Link to comment
Share on other sites

Mhm, I actually tried that but when casting spell, IT didnt cast second spell in formlist second time script was called

 

That means you've got a logic error somewhere. Compiler errors are mostly syntax things -- the equivalent of spelling. Scripts not doing what you want even though they compile is more like arguing with a drunk :v

 

Without knowing exactly what you want to do, diagnosing those is harder, but you're doing some funny things with that loop that could be causing your problem. The loop's logic structure, say for a 3-element formlist, will go:

 

Element 1

Element 2

Element 0

 

Is that the intended idea? If it is, and the spells aren't being cast, try some trace statements to make sure the branches are working. Maybe you don't have the spell in the formlist, or maybe the spell isn't set up correctly, or you're providing the wrong caster or target to the .Cast calls.

Link to comment
Share on other sites

I appreciate your help.
I have 5 spells in the formlist, I would like to call one at a time, one after the other, once at the last spell Go back to (0).

Im either getting all spells casted at once or just the first one, essentially i want 0, then 1, then 2 up to five or however many spells stored in list.

 

This script is casting every spell in the formlist

 

Scriptname Auto_Release_Combination_Script extends activemagiceffect

Spell Property Auto_Store_Combination_Spell Auto
FormList Property Auto_Combination_FormList Auto
Spell Property AF_ReleaseBlastSPELL Auto
Event OnEffectStart(Actor akTarget, Actor akCaster)
Int index = Auto_Combination_FormList.GetSize()
If index As Bool
int nlimit = index +1
While index As Bool
index -=1
Spell TempSpell = Auto_Combination_FormList.GetAt(Index) as spell
If TempSpell && index < nlimit
(Auto_Combination_FormList.GetAt(Index + 1) as spell).Cast(akTarget)
;AF_ReleaseBlastSPELL.cast(akTarget)
else
(Auto_Combination_FormList.GetAt(0) as spell).Cast(akTarget)
;AF_ReleaseBlastSPELL.cast(akTarget)
EndIf
EndWhile
EndIf

EndEvent

 

 

Casted every spell in the formlist aswell.

 

Scriptname Auto_Release_Combination_Script extends activemagiceffect

Spell Property Auto_Store_Combination_Spell Auto
FormList Property Auto_Combination_FormList Auto
Spell Property AF_ReleaseBlastSPELL Auto
Int property Auto_SpellMax auto
Event OnEffectStart(Actor akTarget, Actor akCaster)
Int nSize = Auto_Combination_FormList.GetSize()
If nSize > 0
Spell SpellToCast = Auto_Combination_FormList.GetAt(Index) as spell
int index = 0
int nlimit = nSize - 1
While index < nSize
If SpellToCast && index < nlimit
(Auto_Combination_FormList.GetAt(Index + 1) as spell).Cast(akTarget)
;AF_ReleaseBlastSPELL.cast(akTarget)
;Return - Only casted first spell
else
(Auto_Combination_FormList.GetAt(0) as spell).Cast(akTarget)
;AF_ReleaseBlastSPELL.cast(akTarget)
EndIf
index +=1
EndWhile
EndIf

EndEvent

 

 

I'm not understanding this at all, haha.

Best regards

Edited by GSGlobe
Link to comment
Share on other sites

GSGlobe try to make your script sources more easier. Unfortunately you made it to complicated unnecessary. (KISS - Keep It Short and Simple)

from Max downto Zero

 

Scriptname Auto_Release_Combination_Script extends ActiveMagicEffect
{rewritten by ReDragon 2017}

; https://forums.nexusmods.com/index.php?/topic/6093273-script-wont-compile/
; GSGlobe wrote: "I have 5 spells in the formlist, I would like to call one at a time, one after the other"

  FormList PROPERTY myList auto        ; Auto_Combination_FormList

; -- EVENT --

EVENT OnEffectStart(Actor akTarget, Actor akCaster)
IF (akTarget == Game.GetPlayer())
ELSE
    self.Dispel()
    RETURN    ; - STOP -    not the player, do nothing
ENDIF
;---------------------
    myF_Action(akTarget, myList.GetSize())       ; i == index = Auto_Combination_FormList.GetSize()
ENDEVENT


; -- FUNCTION --

;---------------------------------------
FUNCTION myF_Action(Actor Player, Int i)
;---------------------------------------
;IF (i < 1)
;    RETURN    ; - STOP -    empty formlist detected, edited 25-10 caused by next posting in order
;ENDIF
;---------------------
    i = i - 1                                    ; myList.GetSize() - 1
    WHILE (i >= 0)
        spell sp = myList.GetAt(i) as Spell      ; .GetAt(4), (3), (2), (1), (0)
        IF ( sp )
            sp.Cast(Player as ObjectReference)
        ENDIF
        i = i - 1                                ; break loop, if (i == -1)
    ENDWHILE
ENDFUNCTION

 



from Zero to Max

 

Scriptname Auto_Release_Combination_Script2 extends ActiveMagicEffect
{rewritten by ReDragon 2017}

; https://forums.nexusmods.com/index.php?/topic/6093273-script-wont-compile/
; GSGlobe wrote: "I'm not understanding this at all, haha."

  FormList PROPERTY myList auto        ; Auto_Combination_FormList

; -- EVENT --

EVENT OnEffectStart(Actor akTarget, Actor akCaster)
IF (akTarget == Game.GetPlayer())
ELSE
    self.Dispel()
    RETURN    ; - STOP -    not the player, do nothing
ENDIF
;---------------------
    myF_Action(akTarget, myList.GetSize())       ; iMax == index = Auto_Combination_FormList.GetSize()
ENDEVENT


; -- FUNCTION --

;------------------------------------------
FUNCTION myF_Action(Actor Player, Int iMax)
;------------------------------------------
;IF (iMax < 1)
;    RETURN    ; - STOP -    empty formlist detected, edited 25-10 caused by next posting in order
;ENDIF
;---------------------
    int i = 0
    WHILE (i < iMax)
        spell sp = myList.GetAt(i) as Spell      ; .GetAt(0), (1), (2), (3), (4)
        IF ( sp )
            sp.Cast(Player as ObjectReference)
        ENDIF
        i = i + 1                                ; break loop, if (i == iMax)
    ENDWHILE
ENDFUNCTION

 

 

Edited by ReDragon2013
Link to comment
Share on other sites

Thank you both for your reply, but I think I messed up explaining what Im trying to do here.

 

I dont want the spells in formlist to be cast all at the same time one after another, rather getat(0) first time script is called, When script is called again getat(1) etc

 

This is the original script, works great as is, except IT equips the spell in left hand each time script is called.

I would also like to offer a solution to this, to cast the spell directly instead of equipping in those cases I would run around with a two handed weapon or dont want to equip a spell.

 

 

Scriptname Auto_Release_Combination_Script extends activemagiceffect

 

FormList Property Auto_Combination_FormList Auto

 

Function FunctionName()

 

 

Int nSize = Auto_Combination_FormList.GetSize()

If nSize != 0

Actor player = Game.GetPlayer()

Spell LeftSpell = player.GetEquippedSpell(0)

int index = 0

While index < nSize

Spell TempSpell = Auto_Combination_FormList.GetAt(Index) as spell

If LeftSpell == TempSpell

If index == nSize - 1

player.EquipSpell(Auto_Combination_FormList.GetAt(0) as spell, 0)

else

player.EquipSpell(Auto_Combination_FormList.GetAt(Index + 1) as spell, 0)

EndIf

EndIf

index +=1

EndWhile

EndIf

 

EndFunction

 

 

Perhaps My problem is more clear now, a while might not be the solution?

 

Edit: Should I compare lefthand = index?

Im either getting stuck at getat(0) or IT cast every spell in form, im missing something I cant get to..

Edited by GSGlobe
Link to comment
Share on other sites

Each time the spell is cast, cast a different spell from the list. Got it.

 

You want to increment an index number with each cast and use that to get the spell from your formlist. Unfortunately, magic effects get a new instance of the script each time their respective spell is cast. Therefore you have to do some script work on a maintenance quest script. Set up a quest that is start game enabled or be sure to start it whenever you start the rest of your mod. The point is that the quest has to be running and remain running for the entire duration that the player has this spell.

 

Example script for the quest:

 

 

ScriptName QuestManagerScript extends Quest

Int index = 0

Function CastSpellInList(Actor akTarget, Actor akCaster, Formlist TheList)
    Int iSize = TheList.GetSize()
    If Index == iSize
        Index = 0
    Else
        Index += 1
    EndIf
    Spell SpellToCast = TheList.GetAt(Index) as spell
    If SpellToCast ;is it a valid spell
        SpellToCast.Cast(akTarget)
    Else
        Debug.Trace("Index "+Index+" of formlist ["+TheList+"] does not contain a valid spell.")
    EndIf
EndFunction 

 

 

Example script for the magic effect

 

 

Scriptname Auto_Release_Combination_Script extends activemagiceffect  
 
FormList Property Auto_Combination_FormList Auto
Quest Property MyManagementQuest Auto

Event OnEffectStart(Actor akTarget, Actor akCaster)
    QuestManagerScript QMS = MyManagementQuest as QuestManagerScript
    QMS.CastSpellInList(akTarget,akCaster,Auto_Combination_FormList)
EndEvent 

 

 

 

Be sure to set up the quest script and compile it first. Otherwise the magic effect script will fail to compile.

Link to comment
Share on other sites

Ah! Yes, now this make sense, thanks a bundle for this. I didnt think for a moment about using a quest nor did I think about magiceffect getting a new instance, tunnelsight is that a saying?

 

Thanks alot for your help! I suppose performance wise its good?

 

Best regards

Link to comment
Share on other sites

  • Recently Browsing   0 members

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