/newiff stupid question

Need help running MacroQuest2? Ask your questions about how to get things to work on your computer.

Moderator: MacroQuest Developers

Dantuss
decaying skeleton
decaying skeleton
Posts: 9
Joined: Sun Aug 03, 2003 3:21 pm

/newiff stupid question

Post by Dantuss » Thu Apr 22, 2004 4:15 am

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

Digitalxero
a ghoul
a ghoul
Posts: 129
Joined: Tue Sep 10, 2002 5:01 pm

Post by Digitalxero » Thu Apr 22, 2004 5:14 am

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

wassup
Official Guardian and Writer of TFM
Official Guardian and Writer of TFM
Posts: 1487
Joined: Sat Oct 26, 2002 5:15 pm

Re: /newiff stupid question

Post by wassup » Thu Apr 22, 2004 5:18 am

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

Dantuss
decaying skeleton
decaying skeleton
Posts: 9
Joined: Sun Aug 03, 2003 3:21 pm

Post by Dantuss » Thu Apr 22, 2004 6:16 am

Thanks guys I really apreciate your prompt and accurate replies!

draco
a ghoul
a ghoul
Posts: 145
Joined: Thu Jan 29, 2004 7:06 pm
Contact:

Post by draco » Thu Apr 22, 2004 3:30 pm

Wassup, I see why you maintain the readme. That was an excellent explaination. :D Thanks also.