Page 1 of 1

Nested /if parsing.

Posted: Wed Mar 31, 2004 2:43 pm
by NotHere
Hi.

It seems that nested /if parsing have been changed, and are bugged atm? Not sure when this changed, but it worked differently before the DX9 patch. Havent tried it before the 20040330 version, and there this issued occured. I am running with both MQ2DATATYPES and MQ2PARAMS enabled.

The following is a modified piece from a macro Im working on, thats been changes slightly so it can run by itself.

Code: Select all

| *** Defines for DurSpells array
#define DurSpellName 0
#define DurItemName 1
#define DurCastNext 2
#define DurMaxHealth 3


Sub Main    
  /declare DurSpells array2

  /varset DurSpells(0,DurSpellName) "Tempest Wrath"
  /varset DurSpells(0,DurItemName) "Blade of the Tempest"
  /varset DurSpells(0,DurMaxHealth) 0

  /varset DurSpells(1,DurSpellName) "Swarming Death"
  /varset DurSpells(1,DurMaxHealth) 16  

  /varset DurSpells(2,DurSpellName) "E'ci's Frosty Breath"
  /varset DurSpells(2,DurMaxHealth) 8

  /call TestEvent  
/return
  
Sub TestEvent
  /declare i local
  /declare Para0 local

  /varset Para0 "Your Swarming Death spell has worn off."
  
  /for i 0 to 9
    /if "@DurSpells(@i,DurSpellName)"~~"UNDEFINED" /return
    /echo Checking spell (@i)
    [color=red]/if "@Para0"~~"@DurSpells(@i,DurSpellName)" [/color]{
      [color=red]/echo Spell (@i) matched![/color]
      /if n ${Target.PctHPs}>@DurSpells(@i,DurMaxHealth) {
        [color=red]/varset DurSpells(@i,DurCastNext) TRUE[/color]
        /echo @DurSpells(@i,DurSpellName) faded, and will be renewed.
      } else {
        /echo @DurSpells(@i,DurSpellName) faded, but will not be renewed.
      }
    }
  /next i
/return
Consider the three lines in red. The problem when running this piece is that the /echo line is only executed when the comparison right above is matched. However, the /varset is executed on all three runs through the loop.

Am I using the nesting incorrectly, or is it bugged?

This is still an issue with .zip from March 31 2004 08:46:39.

EDIT: If running this as a test, target yourself and have more than 16% of your HPs, otherwise you will not match the comparison made for target HPs.

Posted: Wed Mar 31, 2004 3:01 pm
by dont_know_at_all
Post the complete output from this macro.

Here's what I would expect:

Code: Select all

Checking spell (0)
Checking spell (1)
Spell (1) matched!
Swarming Death faded, and will be renewed.
Checking spell (2)

Posted: Wed Mar 31, 2004 3:28 pm
by ml2517

Code: Select all

*pulls head out of his ass*

Posted: Wed Mar 31, 2004 3:37 pm
by Lax
He said he has both enabled

Posted: Wed Mar 31, 2004 3:39 pm
by ml2517
Lax wrote:He said he has both enabled
I have become better at reading (66)!

Maybe he's overlooking the fact that he doesn't have them in the actual "test" code he's messing with. I guess in addition to the output DKAA asked for, post the entire piece of code you are testing.

Posted: Wed Mar 31, 2004 3:42 pm
by NotHere
dont_know_at_all wrote:Post the complete output from this macro.
I expected the same as you, but what I actually get is:

Code: Select all

Checking spell (0)
Tempest Wrath faded, and will be renewed
Checking spell (1)
Spell (1) matched
Swarming Death faded, and will be renewed
Checking spell (2)
Eci's Frosty Breath faded, and will be renewed
Thats if I have myself targetted. If I have a clear target, I get:

Code: Select all

Checking spell (0)
Tempest Wrath faded, and will be renewed
Checking spell (1)
Spell (1) matched
Swarming Death faded, but will not be renewed
Checking spell (2)
Eci's Frosty Breath faded, and will be renewed
But by all means, try running it. :)

It can run alone as is.

Posted: Wed Mar 31, 2004 3:43 pm
by NotHere
ml2517 wrote:
Lax wrote:He said he has both enabled
I have become better at reading (66)!

Maybe he's overlooking the fact that he doesn't have them in the actual "test" code he's messing with. I guess in addition to the output DKAA asked for, post the entire piece of code you are testing.
I wasnt aware that I had to add the types here as well.

I have enabled them both in mq2main.h, this isnt enough?

The code above is the complete test code, and can run as is to test the issue

Posted: Wed Mar 31, 2004 3:44 pm
by ml2517
Hmm I was thinking you had to do that in the macro's themselves as well. I haven't really messed with it yet so I'm probably full of shit (tm).

Just went back and re-read the info, looks like you can ignore the comment above.

Posted: Wed Mar 31, 2004 5:47 pm
by dont_know_at_all
/if is broken, apparently.

The } else { is matching the first /if and not the second one.

FailIf is using strstr to count "{" and "}", which is wrong. Working on a fix...

Posted: Wed Mar 31, 2004 6:49 pm
by Lax
Fixed. MQ2-20040331b.

Posted: Wed Mar 31, 2004 11:40 pm
by NotHere
Lax wrote:Fixed. MQ2-20040331b.
/cheer!