Parsing a line of chat

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

Moderator: MacroQuest Developers

Wink-
a ghoul
a ghoul
Posts: 122
Joined: Tue Apr 27, 2004 2:41 pm

Parsing a line of chat

Post by Wink- » Mon May 10, 2004 1:25 am

I know this should be retardedly easy, I just am not used to this stuff so I need help!

I send commands to my bots via a channel and they do the command based on the test.

Code: Select all

/if (${ChatText.Equal[heal]}) { 
   /target ${Sender} 
   /delay 5
   /rs CH %t
   /gsay CH %t
   /call cast "complete healing" gem1
   
    
}
This works great when I send "heal" to the channel it targets me and heals me. However I want it to "parse" the chat text so I can make it do something like this.

JoeSchmoe tells generic channel, "triggerword spellname target" so it will cast spell on the target.
My wordinig might seem confusing but "triggerword CH Happywarrior" would make it target the happywarrior and cast CH on him.

Oid
a snow griffon
a snow griffon
Posts: 416
Joined: Thu Oct 17, 2002 3:26 am
Contact:

Post by Oid » Mon May 10, 2004 1:30 am

I'd look into events....
Smokey the Lax says only you can prevent reproduction.

Wink-
a ghoul
a ghoul
Posts: 122
Joined: Tue Apr 27, 2004 2:41 pm

Post by Wink- » Mon May 10, 2004 1:48 am

The new events style OID? I was thinking of doing that if that is the easiest way.

Oid
a snow griffon
a snow griffon
Posts: 416
Joined: Thu Oct 17, 2002 3:26 am
Contact:

Post by Oid » Mon May 10, 2004 3:14 am

Yes, but old would have been proper prior to new ;)
Smokey the Lax says only you can prevent reproduction.

Rusty~
a hill giant
a hill giant
Posts: 244
Joined: Wed Apr 14, 2004 2:55 pm

Post by Rusty~ » Mon May 10, 2004 4:15 pm

I didn't think #events worked on chat commands.

I have code that does something like this though for chat commands. Changed it a bit so it should do what you want:

Code: Select all

Sub Event_Chat(string chatType,string chatSender,string chatText) 
   /declare n int local
   /declare spellName string local
   /varset n 0
:space_count_loop
   /varcalc n ${n}+1
   /if ( ${chatText.Arg[${Math.Calc[${n}+1]}].Length} ) /goto :space_count_loop
      /if ( ${chatText.Arg[1].Equal[triggerword]} ) {
      /if ( ${chatText.Arg[${Math.Calc[${n}-1]}].Equal[on]} ) {
         /target ${chatText.Arg[${n}]}
         /varset spellName ${chatText.Mid[${Math.Calc[${chatText.Arg[1].Length}+1]},${Math.Calc[${chatText.Length}-${chatText.Arg[1].Length}-${chatText.Arg[${n}].Length}-4]}]}
      } else {
         /varset spellName ${chatText.Mid[${Math.Calc[${chatText.Arg[1].Length}+1]},${Math.Calc[${chatText.Length}-${chatText.Arg[1].Length}]}]}
      }
      /call Cast "${spellName}"
   }
   /return
saying "triggerword complete healing on Happywarrior" would target Happywarrior and cast CH on him. Saying "triggerword complete healing" would just cast CH on the bot's current target

I have a loop in there to count how many words there are. n is equal to the number of words. At first i tried using string.Count[ ] but it wasn't working at the time, not sure if it does now, but the above code should work either way!

Preocts
a snow griffon
a snow griffon
Posts: 312
Joined: Thu Jan 29, 2004 1:02 pm

Post by Preocts » Mon May 10, 2004 5:18 pm

Just a curious question here but wouldn't Chat Event Tell be much more suited to running a bot?

Wink-
a ghoul
a ghoul
Posts: 122
Joined: Tue Apr 27, 2004 2:41 pm

Post by Wink- » Mon May 10, 2004 9:34 pm

Thanks Rusty~ that did exactly what I wanted it to do.

Preocts, I run my 5 other bots in a channel all listening for commands so I don't have to send tells to them all and if I want to give commands to all of them or some of them at once this works out much better. But I need to give commands to my bots to take of my other bots and stuff like that :)

Rusty~
a hill giant
a hill giant
Posts: 244
Joined: Wed Apr 14, 2004 2:55 pm

Post by Rusty~ » Mon May 10, 2004 9:35 pm

is there another way to do chat events other than like:

#chat tell
#chat chat

Ive searched and stuff but the above is the only way ive been able to do it