Page 1 of 1

/newiff stupid question

Posted: Thu Apr 22, 2004 4:15 am
by Dantuss
I am very new to writing macro's and was just getting the hang of using /if statements but after this last patch am having trouble converting some of my macroes due to the /newif

What I need is to be able to tell what target type I have targeted, then based apon target type do something.

/echo ${Target.Type}

Will give "NPC"/"PC" etc

So the /newif I tried below seemed right to me

Code: Select all

/newif (${Target.Type}="NPC") /goto :nextthing

This doesnt work, can some one please give me a hint.

Thanks

Posted: Thu Apr 22, 2004 5:14 am
by Digitalxero
First use /if the old /if does not exist any more and /newif is just and alias for /if.

Second /if just calculates info and if it gets 0 it is false and if it gets 1 it is true so trying to do string compairs like that will not work you have to do it like

Code: Select all

/if ${Target.Type.Equal[NPC]} /goto :nextthing
if you need something like /if "Fun fish"~~"fish" /goto :something

Code: Select all

/if ${String["Fun fish"].Compare[fish]} /goto :something

Re: /newiff stupid question

Posted: Thu Apr 22, 2004 5:18 am
by wassup

Code: Select all

/newif (${Target.Type}="NPC") /goto :nextthing
Tons of hints here: http://macroquest2.com/phpBB2/viewtopic.php?t=6022

Biggest help is to look at the return types for each of the members, and that tells you what members you can use with the return.

For example... Target can use the members of spawn
spawn Target
Looking at spawn... it has the member
string Type: PC NPC Mount Pet Corpse Trigger Item


Type is a string, so lets go look at the members of the string type, oh, look!
bool Equal[text]: Strings equal? Case does not count...
So, combining these...

Target.Type.Equal[NPC]

Then surrounding that with ${ }

Code: Select all

/if (${Target.Type.Equal[NPC]}) /goto :nextthing
This will do /goto :nextthing if your target is an NPC

Posted: Thu Apr 22, 2004 6:16 am
by Dantuss
Thanks guys I really apreciate your prompt and accurate replies!

Posted: Thu Apr 22, 2004 3:30 pm
by draco
Wassup, I see why you maintain the readme. That was an excellent explaination. :D Thanks also.