How to parse text in the chat window

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

Marze
a lesser mummy
a lesser mummy
Posts: 60
Joined: Wed Apr 14, 2004 12:08 pm

How to parse text in the chat window

Post by Marze » Wed Apr 14, 2004 12:24 pm

I've read the manual on the website and searched through these forums but I can't seem to find something that I would think is very fundamental. What is the variable for the last thing to go across the chat window? I'd like to parse this text for a few applications:

Relaying tells: Someone sends my bot a tell and the bot relays it into my chat channel.

Executing commands: I send the command "heal xxxxx" and the cleric sees "heal xxxx" and does /target xxxx /cast "Supernal Remedy"

Thanks.

Marze
a lesser mummy
a lesser mummy
Posts: 60
Joined: Wed Apr 14, 2004 12:08 pm

Post by Marze » Wed Apr 14, 2004 12:41 pm

I think I've found it. Let me know if this will work to relay tells to group:

Code: Select all

#chat tell

Sub Event_Chat(MsgType,MsgFrom,MsgData)
   /g @MsgFrom + ": " + @MsgData
   /return
Should appear as "ClericBot tells the group, 'Soandso: Bla bla bla'"

And is it correct that I do not have to check if the MsgType is a tell, because #chat tell is the only type of chat message that triggers the routine to begin with?

Falco72
a hill giant
a hill giant
Posts: 215
Joined: Fri Sep 26, 2003 3:24 am

Post by Falco72 » Wed Apr 14, 2004 12:55 pm

Yes, if you use only tell as valid chat channel you don't need to check the MsgType.

Remember to use @ before your variable, the right way is

Code: Select all

/gsay @MsgFrom : "@MsgData"
And you can't concat string using + or &, but need to use the /varcat command, i.e.

Code: Select all

/declare mystring local
/varset mystring "@MsgFrom"
/varcat mystring " : "
/varcat mystring "@MsgData"
/gsay "@mystring"

Marze
a lesser mummy
a lesser mummy
Posts: 60
Joined: Wed Apr 14, 2004 12:08 pm

Post by Marze » Wed Apr 14, 2004 1:03 pm

So you build the string bit by bit using varcat. Great.

Whats the difference between "@MsgData" and @MsgData?
I notice you aren't using "@MsgFrom"

sahcruncher
decaying skeleton
decaying skeleton
Posts: 2
Joined: Wed Mar 24, 2004 12:13 pm

Post by sahcruncher » Wed Apr 14, 2004 1:19 pm

The quotes make things with spaces work. @MsgFrom wouldn't need quotes because names don't have spaces. @MsgData needs quotes to relay something with more than one word in it.

ml2517
a grimling bloodguard
a grimling bloodguard
Posts: 1216
Joined: Wed Nov 12, 2003 1:12 am

Post by ml2517 » Wed Apr 14, 2004 1:21 pm

The reason he is using quotes is that if you have spaces in the variable, once expanded, it would only take the first portion of the variable (up to the first space) and tack it on. If you use quotes, it would tack on the full text in the variable.

nolife
decaying skeleton
decaying skeleton
Posts: 9
Joined: Tue Apr 13, 2004 2:49 pm

Post by nolife » Wed Apr 14, 2004 3:54 pm

is there a way to check the color of the text in the chatwindow? ..

i am still searching a way to consider the mobs .. perhaps thats a way to do it ? :?:

and if there is a way .. can you giveme an short example? :oops:

ImaNoob
a ghoul
a ghoul
Posts: 89
Joined: Mon Mar 08, 2004 4:37 am

Consider

Post by ImaNoob » Wed Apr 14, 2004 4:36 pm

In the druidfarm macro, there is a little function that will determine whether or not something is killable, not by the color of the text but by the words.

It works a little something like this.

Code: Select all

Sub Main
                /zapvars
	/cleanup
	/call DefineEvents	
	:Next 
   	     /call GotoNPC
                     /keypress c 
   	/goto :Next 
    
/return

Sub DefineEvents
	#event RED "what would you like your tombstone to say"
                #event YELLOW "would wipe the floor with you"
                #event BLUE "formidable opponent"
                #event GREEN "win this fight"
/return

Sub GotoNPC
       |Place your code for selecting an NPC or mob and going to them here
/return

Sub Event_RED
          /echo Oh shit I'm gonna die
         |Place code to deal with a red mob here
/return

Sub Event_YELLOW
         /echo This is gonna hurt
        |Place code to deal with a yellow mob here
/return

Sub Event_BLUE
         /echo Woot!  I think I can kill it
        |Place code to deal with a blue mob here
/return

Sub Event_GREEN
        /echo Your kidding, you want me to kill that?  Come on gimme a challenge
        |Place greenie code here
/return
This is a start for you, not a fully functioning macro, infact I'm not sure that this would entirely work but it gets you 90% of the way there, enjoy!

*update* WTF? Just ignore the spacing and indentation problems, I put them in properly but it's not being reflected.
Last edited by ImaNoob on Wed Apr 14, 2004 4:37 pm, edited 2 times in total.

ml2517
a grimling bloodguard
a grimling bloodguard
Posts: 1216
Joined: Wed Nov 12, 2003 1:12 am

Post by ml2517 » Wed Apr 14, 2004 4:37 pm

You'll need to find the formula for con colors based on the NPC level and your characters level. Try looking at advchant in the depot I think at one time Raebis added it to his macro.

If you don't need the light blue/light green type info you can probably just use events like above.

Falco72
a hill giant
a hill giant
Posts: 215
Joined: Fri Sep 26, 2003 3:24 am

Post by Falco72 » Wed Apr 14, 2004 4:47 pm

There are two way that I know to con a mob:
first, every time you target a mob press "c" and then evaluate the text using an #event for each con text;
the second, it is to use the $target(level) or $spawn(id,level) command and evalutate the result versus your level. This one, according my opinion, is the best.
Using the search function of this forum you can find some posts (at least one) that speak about con according to your level. for exemple you can use a code like this:

Code: Select all

/declare moblevel local
/varset moblevel $target(level)
/if n @moblevel>$calc($char(level)+1) {
   /echo red mob
} else /if n @moblevel==$calc($char(level)+1) {
   /echo yellow mob
} else /if n @moblevel==$char(level) {
   /echo white mob
} else /if n @moblevel>=$calc($char(level)-10) {
   /echo blue mob
} else /if n @moblevel>=$calc($char(level)-15) {
   /echo light blue mob
} else {
   /echo green mob
}

nolife
decaying skeleton
decaying skeleton
Posts: 9
Joined: Tue Apr 13, 2004 2:49 pm

Post by nolife » Thu Apr 15, 2004 1:46 am

thanx :)

i think that all will help ... i try this this evening and post my testmacro in here


very thanx for help :)