Sub Event_Chat Help please.

Need some help with that macro you're working on or aren't quite sure how to get your macro to do something? Ask here!

Moderator: MacroQuest Developers

Shocks
a ghoul
a ghoul
Posts: 101
Joined: Tue Feb 18, 2003 3:26 pm
Contact:

Sub Event_Chat Help please.

Post by Shocks » Tue Oct 14, 2003 10:53 am

Ok lets say this is my OLD Event_Chat. Ill be damed if I can get it to work converted. I know im doing or not doing something stupid. If someone would be every so kind as to show me the errors of my ways and maybe convert a few lines so I can see what im doing wrong.

I though I should just have to change the $ChatCommand to @ChatCommand and thats is what I did but now im thinking I should have done a /declare ChatCommand ??? Global maybe. I have a ton more questions but Ill leave it at this.

Yes I did remember to change $mastername to @mastername.

Code: Select all

Sub Event_Chat 

:Commands 

| *** Complete Heal *** 

/if "$ChatCommand"=="ch" { 
     /target $mastername
     /stand 
     /g COMPLETE HEAL on %T in 10seconds 
     /call SpellSub 1 105 
     /sit 
     /press esc 

| *** HEAL OVER TIME *** 

   } else /if "$ChatCommand"=="ce" { 
     /target $mastername
     /stand 
     /g Cel Heal >> %T 
     /call SpellSub 1 50 
     /sit 
     /press esc 

| *** Cure Poison *** 

   } else /if "$ChatCommand"=="poison" { 
     /target $mastername
     /stand 
     /g Cure Poison >> %T 
     /call SpellSub 6 50 
     /sit 
     /press esc 

| *** GATE *** 

   } else /if "$ChatCommand"=="gate" { 
     /stand 
     /g Gating 
     /call SpellSub 8 55 
}
/return

Mckorr
Developer
Developer
Posts: 2326
Joined: Fri Oct 18, 2002 1:16 pm
Location: Texas

Post by Mckorr » Tue Oct 14, 2003 11:34 am

$mastername --> @mastername
$ChatCommand --> @ChatCommand

Both of those have to be declared, looks like globals from this small chunk of code.

Code: Select all

/call SpellSub # #
I'm assuming the first number is the gem, and the second is a timer.

Code: Select all

sub SpellSub(gem,time)
   /declare casttimer timer
   /cast @gem  
   /varset casttimer @time
   :WaitLoop
      /if n @casttimer>0 /goto :WaitLoop
/return
Make sure you get you get your parameters right. When you pass the second number it is a local variable, and you have to convert it to a timer.
MQ2: Think of it as Evolution in action.

Shocks
a ghoul
a ghoul
Posts: 101
Joined: Tue Feb 18, 2003 3:26 pm
Contact:

Post by Shocks » Tue Oct 14, 2003 11:39 am

Thanks Mckorr

Ok thats what I though. I NEVER did /declare @ChatCommand Global
I left it as #define ChatCommand P1 or some such thing.

Some day Ill get a handle on this. Thanks again.

Mckorr
Developer
Developer
Posts: 2326
Joined: Fri Oct 18, 2002 1:16 pm
Location: Texas

Post by Mckorr » Tue Oct 14, 2003 12:03 pm

Also, /declare goes INSIDE a sub, not before sub Main like #define did.

And variables are casesensitive. Made that mistake a lot yesterday while combining my bard twisting macro with my melee macro into one that will melee while twisting.
MQ2: Think of it as Evolution in action.

Shocks
a ghoul
a ghoul
Posts: 101
Joined: Tue Feb 18, 2003 3:26 pm
Contact:

Post by Shocks » Wed Oct 15, 2003 9:46 am

Well Mkorr

I tryed it and no go. So I went back and read the post again where plaz explains it all and here is what I found.

From what I can tell you dont have to declare anything. You just have to pick what you want it to look for, ChatType, Sender, ChatText. Now im not sure if (ChatType,Sender,ChatText) needs to be there but it is in mine. I took out all those @ChatCommands in my macro replaced them with @ChatText and BOOM it works like a charm.

Code: Select all

Sub Event_Chat(ChatType,Sender,ChatText)  
   /if @Sender!=@gBotOwner /return 
   /echo @Sender sent me a @ChatType, '@ChatText' 
   /if "@ChatText"=="quit" /varset gShouldQuit TRUE 
/return 
I have no idea why I could not understand that but after oo the 25th time I looked at what he wrote it clicked. I keep trying to make stuff harder than it is now. The more I understand what Plaz did the more I enjoy it.

Thanks again.
Shocks

Mckorr
Developer
Developer
Posts: 2326
Joined: Fri Oct 18, 2002 1:16 pm
Location: Texas

Post by Mckorr » Wed Oct 15, 2003 9:50 am

Ah, thanks. I don't do bots, so I've never played with Event_Chat.

BTW did you really have to use Hungarian notation? lol
gShouldQuit
MQ2: Think of it as Evolution in action.

Shocks
a ghoul
a ghoul
Posts: 101
Joined: Tue Feb 18, 2003 3:26 pm
Contact:

Post by Shocks » Wed Oct 15, 2003 9:57 am

Talk to plaz bro that was a cut and paste from.

http://macroquest2.com/phpBB2/viewtopic ... 19&start=0

Mckorr
Developer
Developer
Posts: 2326
Joined: Fri Oct 18, 2002 1:16 pm
Location: Texas

Post by Mckorr » Wed Oct 15, 2003 10:18 am

No thanks, I've seen the sourcecode (shudder).

Sorry, I just hate that way of writing variables. Even Microsoft (who apparently started it in the first place) is now trying to get away from it.
MQ2: Think of it as Evolution in action.