Page 1 of 1

Parsing a line of chat

Posted: Mon May 10, 2004 1:25 am
by Wink-
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.

Posted: Mon May 10, 2004 1:30 am
by Oid
I'd look into events....

Posted: Mon May 10, 2004 1:48 am
by Wink-
The new events style OID? I was thinking of doing that if that is the easiest way.

Posted: Mon May 10, 2004 3:14 am
by Oid
Yes, but old would have been proper prior to new ;)

Posted: Mon May 10, 2004 4:15 pm
by Rusty~
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!

Posted: Mon May 10, 2004 5:18 pm
by Preocts
Just a curious question here but wouldn't Chat Event Tell be much more suited to running a bot?

Posted: Mon May 10, 2004 9:34 pm
by Wink-
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 :)

Posted: Mon May 10, 2004 9:35 pm
by Rusty~
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