Page 1 of 4
**solved** proper /if syntax
Posted: Thu Oct 06, 2005 10:02 pm
by ultimateq
http://www.macroquest2.com/wiki/index.php//if I edited the wiki as best as I could. I am a complete newb to macroing. the extent of my "programming" knowlege is xhtml or "replace X on line X with X" not that I knew what I acctually changed. I tried to follow the manual as best as possible. Not realising there was a wiki.
OK here I go.
What would be the proper way to check to see if the channel is not the default "mychannel"? and do the /goto :whatever command?
I tried /if. But i do not fully understand how that works. here is the syntax i tried incase it helps.
Code: Select all
/if (${channel.Equal[mychannel]}) {
/goto :line }
I also tried something like this
Code: Select all
/if (${channel}=={mychannel}) {/goto :line}
based off other threads i found.
Show me once and I'll know forever.
Thanks again for your help. I really appreciate it
Posted: Thu Oct 06, 2005 10:52 pm
by NeXuS
No need to put an /if statement on joining a channel for a macro just get it to join after declares. (replace the healLpassword with your channel)
Code: Select all
/declare MyChannel string outer heal:password
/join ${MyChannel}
Or alternate not sure if this code is right put a /call Mychannel for it in your :mainloop
Code: Select all
Sub Mychannel
/if (${Channel.NotEqual[${MyChannel}]}) {
/echo joining ${MyChannel} now
/join ${MyChannel}
/announce on
}
/return
Posted: Thu Oct 06, 2005 11:24 pm
by ultimateq
You rock. It isnt exactly what i was asking for. But, I do understand better on how the /if command works..
I can't seem to find anything on the /announce command. Mind enlightening me?
Thanks
Posted: Thu Oct 06, 2005 11:32 pm
by NeXuS
with /goto - Announce lets you know when other people join channel
Code: Select all
/if (${Channel.NotEqual[${MyChannel}]}) /goto :line
Code: Select all
/if (${channel}=={mychannel}) /goto :line
Posted: Fri Oct 07, 2005 12:02 am
by ultimateq
I owe you one. You helped me out alot
Posted: Fri Oct 07, 2005 1:29 am
by nils
This is more than you asked for but here is a simple little macro that shows how you can do it with a chat event instead. Just start the macro, join mychannel with another toon and have that toon say blah in mychannel. I didn't use the /goto command but instead called another sub. They say using /goto is not as efficient. Also I used the chat text to trigger calling the sub I wanted instead of just any text in mychannel so that you could call different subs based on what chat you recieved and it only responds to chat in mychannel.
Code: Select all
| chat.mac
#Chat Chat
Sub Main
/declare channel string outer mychannel
/join ${channel}
:Main_Loop
/delay 1
/doevents
/goto :Main_Loop
/return
Sub SomeSub
/chat #${channel} If this is working you should see this First
/return
Sub event_Chat(string ChatType,string Sender,string ChatText)
/if (${ChatType.Equal[${channel}]}) {
/if (${ChatText.Equal[bla]} || ${ChatText.Equal[bla bla]} || ${ChatText.Equal[blah]} || ${ChatText.Equal[blah blah]}) /call SomeSub
/chat #${channel} You should see this Second
/tell ${Sender} it worked!
}
/return
Posted: Fri Oct 07, 2005 1:52 am
by ultimateq
I don't think you guys quite understand, how much you have seriously helped me out.
Nils you answered another stupid question of mine. as how do i make the mac talk in the specified channel.
All I really wanted to do with the channel thing. Is.
if the channel is set to "mychannel" (the default channel). it would /goto :failed
Code: Select all
/if (${channel.Equal[mychannel]}) {
/goto :failed
}
:failed
/echo You did not change the default channel.
/echo Ending the Macro.
/end
Is that anywhere near close?
Posted: Fri Oct 07, 2005 3:06 am
by NeXuS
That should work but like nils said better to call a sub then a /goto
Posted: Fri Oct 07, 2005 11:28 am
by ultimateq
Wow i got it right.
Thanks for the tips. I think i'll call a sub instead

Posted: Fri Oct 07, 2005 11:31 am
by A_Druid_00
Yeah, when possible /goto should be avoided. It's generally slower, and is usually just used a a cheap workaround for something that's easily done with a separate sub. I still have a /goto or 3 in my AutoBot macro, but I try to use them sparingly.
Posted: Fri Oct 07, 2005 12:01 pm
by ultimateq
Makes sence.
The manual isnt very clear on the /declare types. such as int or string.
I understand how local, global, and outer work. I just don't fully understand what int and string does.
Posted: Fri Oct 07, 2005 12:25 pm
by gimp
ultimateq wrote:Makes sence.
The manual isnt very clear on the /declare types. such as int or string.
I understand how local, global, and outer work. I just don't fully understand what int and string does.
int gives you a variable to store whole numbers (integers)
string gives you a variable to store strings, like "hello world"
Posted: Fri Oct 07, 2005 12:28 pm
by ultimateq
That makes perfect sence. is it required to use int or string on a declare?
Posted: Fri Oct 07, 2005 12:36 pm
by A_Druid_00
string is the default, so if you don't specify it will be a string. You can't do numeric comparisons on a string though, you have to use things like .Find, .Equal, and .NotEqual to evaluate them. With an integer you can do things like:
Code: Select all
/if (${SomeInt}>1) {
/dosomethingneato
}
Posted: Fri Oct 07, 2005 1:26 pm
by ultimateq
alright and this brings me to hopefully my last question. are quotes required for anything the declares.
such as
Code: Select all
/declare myvar int outer "20"
/declare mynextvar string outer "i like cookies"