validation of 1 line of code

Need help with a macro you are writing? Ask here!

Moderator: MacroQuest Developers

aesian
orc pawn
orc pawn
Posts: 10
Joined: Fri Jan 07, 2011 9:00 am

validation of 1 line of code

Post by aesian » Wed Jan 12, 2011 8:56 am

if i have MQ2Cast

would this work

/if ({Cast.Ready} && !{Cast.Ready[Minor Shielding|gem1]}) /delay 1s /casting "Minor Shielding" 1 -maxtries|5 -targetid|Buffreceivername.ID



info : buffreceivername = the name of char that wants to receive buffs

drzoon
a hill giant
a hill giant
Posts: 239
Joined: Tue May 04, 2004 5:38 pm

Re: validation of 1 line of code

Post by drzoon » Wed Jan 12, 2011 9:44 am

There's a number of errors in that single line:
  • You need a $ in front of both Cast.Ready statements. Eg. ${Cast.Ready} or ${Cast.Ready[Minor Shielding|gem1]}
  • You have a ! in front of the 2nd Cast.Ready statement, which negates that statement. Your if statement basically says "If I'm ready to cast and not ready to cast Minor Shielding, then cast Minor Shielding".
  • You can't have both the /delay and /cast statements on the same line, as they are separate commands. You need to have them on separate lines with in a code block.
  • You can't use Buffreceivername like that. First off, if it's a variable, then it needs to be ${Buffreceivername}. If you're going to hard-code a name instead of Buffreceivername, then you don't need the brackets though. Secondly, in order to get the ID of a particular spawn (PC, NPC, corpse, pet, etc), you need to use the ${Spawn} TLO and access the .ID member. Eg. ${Spawn[${Buffreceivername}].ID} or ${Spawn[Buffreceivername].ID}.
So to do what I think you want to do, you should use the following code:

Code: Select all

/if (${Cast.Ready} && ${Cast.Ready[Minor Shielding|gem1]}) {
  /delay 1s
  /casting "Minor Shielding" 1 -maxtries|5 -targetid|${Spawn[${Buffreceivername}].ID}
}
A couple of other observations:
  • The first ${Cast.Ready} check is unnecessary, since the thing you want to check is whether Minor Shielding is available to be cast. If ${Cast.Ready[Minor Shielding|gem1]} returns TRUE, then ${Cast.Ready} will always return TRUE.
  • The delay seems unnecessary, since if the spell is available to cast, why wait for a second, why not just cast it immediately?