Looking for macro to add numbers from chat

Have a macro idea but not sure where to start? Ask here.

Moderator: MacroQuest Developers

ultrao5
decaying skeleton
decaying skeleton
Posts: 9
Joined: Wed Mar 17, 2010 6:25 pm

Looking for macro to add numbers from chat

Post by ultrao5 » Wed Mar 17, 2010 6:28 pm

not sure if its possible but looking for a macro that will read say, chat in format of person says, 5 + 1 = ? and then be able to say the answer or anything close to that. Thanks

Shadows91
a lesser mummy
a lesser mummy
Posts: 31
Joined: Mon Feb 09, 2009 11:21 pm

Re: Looking for macro to add numbers from chat

Post by Shadows91 » Fri Mar 19, 2010 1:15 pm


ultrao5
decaying skeleton
decaying skeleton
Posts: 9
Joined: Wed Mar 17, 2010 6:25 pm

Re: Looking for macro to add numbers from chat

Post by ultrao5 » Sat Mar 27, 2010 2:22 am

Thanks! kinda forgot about my thread and gave up. so now that the math can be done any suggestions on getting mq to read chat and throw it into a /echo ${Math.Calc[#+#]} ?

ok after some testing i almost have it down. heres the basic idea

Code: Select all

#turbo 40
#chat say
| ###########
Sub Main 
| ###########

| ###########
:Main_Loop 
| ###########
  |- Good Luck!
  /delay 1s
  /doevents
  /goto :Main_Loop 
  /return 
| ###########
Sub Event_Chat(string ChatType,string ChatText)
| ###########
/if (!${Select[${ChatType},SAY]} && !${Select[${ChatText}]}) || ${Select[${ChatText},I,NULL]}) /return

/if (${ChatType.Equal[SAY]}) { 
        /echo ${ChatText}
        /return 
      } 
(i know its getto code)this part works great on getting say echo'd. now i tried below.

Code: Select all

/if (${ChatType.Equal[SAY]}) { 
        /echo ${Math.Calc[${ChatText}]} 
        /return 
      } 
im almost there..if the say is just 3 + 1 then it works perfect..but the say is (3 + 1 = ?) from the npc. So how do i pull just the numbers or get the {chatext} to stop at the = to avoid a null return.

Thanks again for the help so far


ultrao5
decaying skeleton
decaying skeleton
Posts: 9
Joined: Wed Mar 17, 2010 6:25 pm

Re: Looking for macro to add numbers from chat

Post by ultrao5 » Mon Mar 29, 2010 1:08 am

thanks for the link one question though, i get the whole token arg part but one issue, when using the /declare TestString ABC,,DEF IE the numbers said are random each time. (unless im missing something not sure this will help) maybe a little back ground history. its kinda a game. theres 6 steps each step the numbers increase by a digit. so part 1 will be 0-9 + 0-9 = ? then part 2 is 10-99 + 10-99, etc each time increasing to a 6 digit number addition. The numbers are always random and like never the same so cant factor that into the macro. With that info is this something still possible.

drzoon
a hill giant
a hill giant
Posts: 239
Joined: Tue May 04, 2004 5:38 pm

Re: Looking for macro to add numbers from chat

Post by drzoon » Mon Mar 29, 2010 7:16 am

How about:

Code: Select all

/echo ${Math.Calc[${ChatText.Arg[1,=]}]}

ultrao5
decaying skeleton
decaying skeleton
Posts: 9
Joined: Wed Mar 17, 2010 6:25 pm

Re: Looking for macro to add numbers from chat

Post by ultrao5 » Mon Mar 29, 2010 1:11 pm

awesome, its kinda funny soon as i made my post i thought of something like that but thought it wouldnt work w/o using the declare part.

ultrao5
decaying skeleton
decaying skeleton
Posts: 9
Joined: Wed Mar 17, 2010 6:25 pm

Re: Looking for macro to add numbers from chat

Post by ultrao5 » Mon Mar 29, 2010 6:14 pm

ok im running into an issue with the macro, with it running first time i get a say message it errors out. the error is unparsable calculation: H which im thinking is the first letter of the player so its picking up the soandso says, and not the actual thing they say.

ultrao5
decaying skeleton
decaying skeleton
Posts: 9
Joined: Wed Mar 17, 2010 6:25 pm

Re: Looking for macro to add numbers from chat

Post by ultrao5 » Mon Mar 29, 2010 6:24 pm

Ive been playing around with /echo ${ChatText.Left[-2]} and its darn near perfect, i can just use that to cut out the last 2 characters being the = and ? only issue now is getting it to skip the name and just read the say message.

ultrao5
decaying skeleton
decaying skeleton
Posts: 9
Joined: Wed Mar 17, 2010 6:25 pm

Re: Looking for macro to add numbers from chat

Post by ultrao5 » Mon Mar 29, 2010 6:41 pm

blah nevermind i figured out the name part, i forgot to list string ChatSender in my sub and now it shows the message. gonna do some testing but think this is gonna do it.

ultrao5
decaying skeleton
decaying skeleton
Posts: 9
Joined: Wed Mar 17, 2010 6:25 pm

Re: Looking for macro to add numbers from chat

Post by ultrao5 » Mon Mar 29, 2010 7:52 pm

it works perfect now but theres one issue if anything is said in say that contains letters it errors and stops. theres a countdown message "you have 25 seconds left" is there anyway to ignore that and just parse the number part. im lost here

ultrao5
decaying skeleton
decaying skeleton
Posts: 9
Joined: Wed Mar 17, 2010 6:25 pm

Re: Looking for macro to add numbers from chat

Post by ultrao5 » Tue Mar 30, 2010 2:07 am

ok Thanks everyone for the help. Finally got it

Code: Select all

#turbo 40
#chat say


|############
| Main
|############
Sub Main


  :loop
  /doevents chat
  /goto :loop

  /return 

|############
| Chat
|############
Sub Event_Chat(string ChatType,string Sender,string ChatText)


/if (${ChatText.Find[you]}) {
      /echo Spam 
      } else {
      /echo ${Math.Calc[${ChatText.Left[-2]}]}

       } 

   /return

GoldenFrog
a ghoul
a ghoul
Posts: 87
Joined: Mon Jan 31, 2005 5:58 pm

Re: Looking for macro to add numbers from chat

Post by GoldenFrog » Mon Apr 05, 2010 5:24 pm

I don't remember subscribing to the ultrao5 blog

FrankJScott
naggy
naggy
Posts: 2365
Joined: Sun Feb 19, 2023 7:11 am

Useful Product Guide

Post by FrankJScott » Fri Aug 18, 2023 11:11 pm

Why don't you Google it! before you post