Page 1 of 1

Looking for macro to add numbers from chat

Posted: Wed Mar 17, 2010 6:28 pm
by ultrao5
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

Re: Looking for macro to add numbers from chat

Posted: Fri Mar 19, 2010 1:15 pm
by Shadows91

Re: Looking for macro to add numbers from chat

Posted: Sat Mar 27, 2010 2:22 am
by ultrao5
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

Re: Looking for macro to add numbers from chat

Posted: Sat Mar 27, 2010 12:13 pm
by Shadows91

Re: Looking for macro to add numbers from chat

Posted: Mon Mar 29, 2010 1:08 am
by ultrao5
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.

Re: Looking for macro to add numbers from chat

Posted: Mon Mar 29, 2010 7:16 am
by drzoon
How about:

Code: Select all

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

Re: Looking for macro to add numbers from chat

Posted: Mon Mar 29, 2010 1:11 pm
by ultrao5
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.

Re: Looking for macro to add numbers from chat

Posted: Mon Mar 29, 2010 6:14 pm
by ultrao5
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.

Re: Looking for macro to add numbers from chat

Posted: Mon Mar 29, 2010 6:24 pm
by ultrao5
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.

Re: Looking for macro to add numbers from chat

Posted: Mon Mar 29, 2010 6:41 pm
by ultrao5
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.

Re: Looking for macro to add numbers from chat

Posted: Mon Mar 29, 2010 7:52 pm
by ultrao5
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

Re: Looking for macro to add numbers from chat

Posted: Tue Mar 30, 2010 2:07 am
by ultrao5
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

Re: Looking for macro to add numbers from chat

Posted: Mon Apr 05, 2010 5:24 pm
by GoldenFrog
I don't remember subscribing to the ultrao5 blog

Useful Product Guide

Posted: Fri Aug 18, 2023 11:11 pm
by FrankJScott
Why don't you Google it! before you post