${If[,,]} evaluating all possible cases?

A forum for reporting bugs NOT related to custom plugins.

Moderator: MacroQuest Developers

User avatar
gimp
a grimling bloodguard
a grimling bloodguard
Posts: 584
Joined: Fri Oct 29, 2004 9:28 am
Location: internet

${If[,,]} evaluating all possible cases?

Post by gimp » Mon Aug 01, 2005 9:25 am

Code: Select all

${If[${Me.Gem[2].ID},${Math.Calc[${Me.CurrentMana}/${Me.Gem[2].Mana}]},]}
Hello. I am attempting to add a counter to my UI that shows "current memmed spell can be cast another X times before you are out of mana".

The above code does just this. But if a spell is not memorized, ${Me.Gem[2].ID} is NULL, but the ${Math.Calc[] code still gets executed, and results in a division by zero error.
Is this the intended behaviour, or am I mis-using ${If[,,]} ?

User avatar
gimp
a grimling bloodguard
a grimling bloodguard
Posts: 584
Joined: Fri Oct 29, 2004 9:28 am
Location: internet

Post by gimp » Mon Aug 01, 2005 9:37 am

here is a work around:

Code: Select all

${If[${Me.Gem[2].ID},${Math.Calc[${Me.CurrentMana}/(${Me.Gem[2].Mana}+0.01)]},]}
but im still curious about the original problem

Lord_Vyper
a hill giant
a hill giant
Posts: 169
Joined: Sat Sep 25, 2004 1:57 am

Post by Lord_Vyper » Mon Aug 01, 2005 10:07 am

If isn't the problem here...

edit: to clarify a bit further, I don't believe if checks if a variable is present before it processes it. So on one hand yes, it's if's problem. On the other hand, you could always nest Ifs to check if a variable is set before you try to mess with it.

Lax
We're not worthy!
We're not worthy!
Posts: 3524
Joined: Thu Oct 17, 2002 1:01 pm
Location: ISBoxer
Contact:

Post by Lax » Mon Aug 01, 2005 10:20 am

It has nothing to do with If, it has to do with MQ2Data. All data sequences are processed from the inside to the outside, regardless of anything else in the statement. The only time it's different is when specific commands (no top-level objects such as If) prevent processing of data sequences.

This is intended behavior.
Lax Lacks
Master of MQ2 Disaster
Purveyor of premium, EULA-safe MMORPG Multiboxing Software
* Multiboxing with ISBoxer: Quick Start Video
* EQPlayNice, WinEQ 2.0

User avatar
gimp
a grimling bloodguard
a grimling bloodguard
Posts: 584
Joined: Fri Oct 29, 2004 9:28 am
Location: internet

Post by gimp » Mon Aug 01, 2005 11:04 am

Ok, thank you for clarifying Lax