• Please note: In an effort to ensure that all of our users feel welcome on our forums, we’ve updated our forum rules. You can review the updated rules here: http://forums.wolflair.com/showthread.php?t=5528.

    If a fellow Community member is not following the forum rules, please report the post by clicking the Report button (the red yield sign on the left) located on every post. This will notify the moderators directly. If you have any questions about these new rules, please contact support@wolflair.com.

    - The Lone Wolf Development Team

Multiple conditionals in Eval Rule - possible syntax bug?

Gamefrog

New member
I'm attempting to create a Class Special for a homebrew class that allows the user to select 2 out of 4 spells on a fighter-type class that they'll be able to use.

While attempting to create the Eval Rule script to check that the user hasn't selected the same spell twice, I kept coming up against a syntax error that seems to be in error itself.

According to Mathias in another thread, I should legitimately be able to have multiple conditionals for my validif statement while using a tagexpr[]
No, you can't combine them like you wanted to (unless you can write things as a tagexpr[] inside a single if () then, since a tagexpr can handle more complex logic).

This was my Eval Rule script:

Code:
    validif (field[usrChosen1].ischosen + field[usrChosen2].ischosen < 2)
~ Check for duplicate selection
    validif (tagexpr[count:Kami.spAugury < 2 & count:Kami.spDeteEvil < 2 & count:Kami.spSpeaDead < 2 & count:Kami.spSpeaPlan < 2])


Which would produce the following error while testing/compiling:

PHP:
Hero Lab was forced to stop compilation after the following errors were detected:

Syntax error in 'evalrule' script for Thing 'cSamCWWotK' (Eval Rule '#1') on line 3
  -> Error parsing left-side expression in relational comparison

Switching out validif for an if/then produced the same exact error.

When I tried this variation:

Code:
    validif (field[usrChosen1].ischosen + field[usrChosen2].ischosen < 2)
~ Check for duplicate selection
    validif (tagexpr[tagcount[Kami.spAugury] < 2 & tagcount[Kami.spDeteEvil] < 2 & tagcount[Kami.spSpeaDead] < 2 & tagcount[Kami.spSpeaPlan] < 2])

I received this error instead:

PHP:
Hero Lab was forced to stop compilation after the following errors were detected:

Syntax error in 'evalrule' script for Thing 'cSamCWWotK' (Eval Rule '#1') on line 3
  -> Invalid tag template specified: 'tagcount[Kami.spAugury]'

The only way I was able to get it to work and function properly was with this (which seemed like a lot more work):

Code:
    validif (field[usrChosen1].ischosen + field[usrChosen2].ischosen < 2)
~ Check for duplicate spell selection
    if (tagcount[Kami.spAugury] >= 2) then
       @valid = 0
    elseif (tagcount[Kami.spDeteEvil] >= 2) then
       @valid = 0
    elseif (tagcount[Kami.spSpeaDead] >= 2) then
       @valid = 0
    elseif (tagcount[Kami.spSpeaPlan] >= 2) then
       @valid = 0
    else
       @valid = 1
    endif

I'm exceptionally new to coding in HL, so I don't know if I wrote the script wrong the first couple of ways, but from everything I was digging up it *should* have worked? :confused: Just wondering if there is a more elegant way to have coded that, and/or if this is a syntax bug with the editor/compiler that it won't parse the tagexpr[] statement properly?

As an additional (related) matter - am I correct in that there is no way to place a bootstrap conditional on the spells so only the 2 that the user has selected will show? From what I've been reading, the conditionals get checked way before my custom tags would be assigned from the user selections of the spells. If anyone can think of a magical answer to make this work, I'd appreciate being pointed in the right direction
 
Back
Top