Parsing tells for specific word, lockups

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

AarynD
a lesser mummy
a lesser mummy
Posts: 45
Joined: Thu Jan 02, 2003 11:25 am

Parsing tells for specific word, lockups

Post by AarynD » Tue Oct 21, 2003 8:30 pm

Code: Select all

#chat tell 

Sub main 

| ----- Trigger Declares --------------------- 

| ----- Variables ---------------------------- 
/Declare teller   global
/Declare rodtf    global
/goto :Wait 
/return 

:Wait 
   /DoEvents 
/goto :Wait 

Sub Event_Chat
/varset rodtf $instr(ROD,$ucase("@Param2"))
/varset teller @Param1 
/if n @rodtf>0 {
  /echo @teller needs rod.
  /target @teller
  /sit off
|  /call cast "Rod of Mystical Transvergance"
  /cast 5
}
/doevents 
/return 

I've also tried this, which USED to work before the var changes and last patch, altho it would cause the IF statement to issue a msg about not finding comparison operator...

Code: Select all

Sub Event_Chat 
/if "$ucase(@Param2)"~~"ROD" {
/target @Param1
/sit off
/cast 5
}
This causes entire machine to lock up, depending on what i'm sent in tell. Any ideas? Parsing strings with vars seems to be a hit and miss thing in MQ :(

Would appreciate some help, if anyone sees a way to do this.

Zxeses
a ghoul
a ghoul
Posts: 103
Joined: Tue Jan 07, 2003 4:17 pm

Post by Zxeses » Wed Oct 22, 2003 11:27 am

First, a few changes to the script ...

1. teller and rodtf dont need to be globals.
2. Bad code readability using /goto outside of the subs end, and not really needed.
3. Never Never Never call /doevents inside of an event, bad logic..

Code: Select all

#chat tell 

Sub main 

:Wait 
   /Doevents
   /delay 1
   /goto :Wait 

/return 


Sub Event_Chat(MsgType, MsgFrom, MsgData)

   /if n $strlen(@MsgData)>0 /if n "@MsgData"~~rod { 
      /echo @MsgFrom needs a rod. 
      /target PC @MsgFrom
      /stand
      /cast 5 
   }
/return 


AarynD
a lesser mummy
a lesser mummy
Posts: 45
Joined: Thu Jan 02, 2003 11:25 am

Doesn't work, still has parsing errors.

Post by AarynD » Fri Oct 24, 2003 9:37 am

Script still not working, and causing lockups.

I rewrote simply to test what's going on. Doing this from work, and from memory, but pretty sure I'm accurate on what I was getting...

Code: Select all

Sub Event_Chat(MsgType, MsgFrom, MsgData)
/echo @MsgFrom | works fine
/echo @MsgData  | works fine
/varset uconvert $ucase("@MsgData")
/echo @uconvert | works fine
/varset npos $InStr(ROD,"@uconvert")
/echo @npos | returns -1, even if ROD is in the string
/return
The reasoning here is, I want to be able to detect the presence of ROD in a sentence, regardless of case, and regardless of how someone forms their request to me, so long as rod is in the tell somewhere.

If I code this:

Code: Select all

/if "@MsgData"~~"ROD"
then I get a macroquest error, stating there's not a valid comparison operator. So of the message to me is "I need a rod please.", it becomes /If "I need a rod please."~~"ROD", and the if statement isn't working correctly with a string with spaces in the first part of the comparison.

The problem compounds when someone sends certain chars in their tells. If I get a "<grin>" or a "=)" sent to me in a tell, the computer locks up, and I have to reboot. Every time.

Any other ideas?

wassup
Official Guardian and Writer of TFM
Official Guardian and Writer of TFM
Posts: 1487
Joined: Sat Oct 26, 2002 5:15 pm

Maybe try this?

Post by wassup » Fri Oct 24, 2003 12:51 pm

Code: Select all

#chat tell 

Sub main 
   :Wait 
      /doevents tell
   /goto :Wait
/return

Sub Event_Chat 
   /if "@Param2"~~"rod" { 
      /echo @Param1 needs rod. 
      /target @Param1
      :WaitTarget
      /if $target(name)!=@Param1 {
         /delay 0
         /goto :WaitTarget
      }
      /sit off
      /delay 0
      /cast "Rod of Mystical Transvergance"
      :WaitCast
      /if $char(casting)==TRUE {
         /delay 0
         /goto :WaitCast
      }
    } 
    /doevents flush
/return

Mckorr
Developer
Developer
Posts: 2326
Joined: Fri Oct 18, 2002 1:16 pm
Location: Texas

Post by Mckorr » Fri Oct 24, 2003 1:15 pm

Parameters start from 0, not 1. So it would be @Param0 and @Param1. Currently you are checking against a parameter (@Param2) which will be undefined if you are only passing two parameters to the sub.
MQ2: Think of it as Evolution in action.