Stumped on this

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

onetimehero
a ghoul
a ghoul
Posts: 105
Joined: Fri Sep 05, 2003 2:42 pm

Stumped on this

Post by onetimehero » Sun Oct 26, 2003 2:52 pm

I'm trying to write a loot value watching script to get an idea of the total value of looted stuff while in a group. Of course, it's based on *my* sell price, so just an estimation. This is the chat code i'm trying to use to capture prices offered by vendors for items, and i'm stumped. It CTD every time. Could some macro guru point out my stupidity?

Code: Select all

Sub Event_Chat
/declare price local
/declare item local
/declare cleanstr local
/declare l1 local
/declare l2 local
/varset l1 0
/varset l2 0

/if "@Param0"=="tell" {
  /mqlog I was told @Param2 by @Param1
  /if "@Param2"~~"I'll give you " {
    /if "@Param2"~~"absolutely nothing" /return
    /mqlog past "give you" check
    /if "@Param2"~~" per " {
      /mqlog stackable item price
      /varset price $mid(15,$calc($instr(" per ",@Param2)-1),@Param2)
      /varset l1 $calc($instr(" per ", @Param2)+5)
      /varset item $mid(@l1,$calc($strlen(@Param2)-@l1),@Param2)
      /mqlog calling ParseAndCheckPrice @price @item
      /call ParseAndCheckPrice @price @item
    } else /if "@Param2"~~" for the " {
      /mqlog Unstackable item price
      /varset cleanstr "$mid(14,$calc($strlen("@Param2")-14),"@Param2")
      /mqlog cleanstr is @cleanstr
      /varset l2 $instr("for","@cleanstr")
      /varcalc l1 @l2-1
      /mqlog l1 is @l1 should be length of price string
      /varset price "$left(@l1,"@cleanstr")"
      /mqlog price is "@price"
      /varset l2 "$instr("the", "@cleanstr")"
      /mqlog l2 is @l2
      /varcalc l1 @l2+5
      /mqlog l1 is @l1 should be start of Item Name
      /varset item "$mid(@l1,$calc($strlen("@cleanstr")-@l1-1),"@cleanstr")"
      /mqlog calling ParseAndCheckPrice @price @item
      /call ParseAndCheckPrice @price @item
    }
  }
}
/return
Thanks.
Hmm. That's odd.

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

Post by wassup » Sun Oct 26, 2003 3:41 pm

Maybe the changes in light blue will help:

Code: Select all

Sub Event_Chat 
/declare price local 
/declare item local 
/declare cleanstr local 
/declare l1 local 
/declare l2 local 
/varset l1 0 
/varset l2 0 

/if "@Param0"=="tell" { 
  /mqlog I was told @Param2 by @Param1 
  /if "@Param2"~~"I'll give you " { 
    /if "@Param2"~~"absolutely nothing" /return 
    /mqlog past "give you" check 
    /if "@Param2"~~" per " { 
      /mqlog stackable item price 
      /varset price $mid(15,$calc($instr(" per ",[color=cyan]"@Param2"[/color])-1),[color=cyan]"@Param2"[/color]) 
      /varset l1 $calc($instr(" per ", [color=cyan]"@Param2"[/color])+5) 
      /varset item $mid(@l1,$calc($strlen([color=cyan]"@Param2"[/color])-@l1),[color=cyan]"@Param2"[/color]) 
      /mqlog calling ParseAndCheckPrice @price @item 
      /call ParseAndCheckPrice @price @item 
    } else /if "@Param2"~~" for the " { 
      /mqlog Unstackable item price 
      /varset cleanstr "$mid(14,$calc($strlen("@Param2")-14),"@Param2") 
      /mqlog cleanstr is @cleanstr 
      /varset l2 $instr("for","@cleanstr") 
      /varcalc l1 @l2-1 
      /mqlog l1 is @l1 should be length of price string 
      /varset price "$left(@l1,"@cleanstr")" 
      /mqlog price is "@price" 
      /varset l2 "$instr("the", "@cleanstr")" 
      /mqlog l2 is @l2 
      /varcalc l1 @l2+5 
      /mqlog l1 is @l1 should be start of Item Name 
      /varset item "$mid(@l1,$calc($strlen("@cleanstr")-@l1-1),"@cleanstr")" 
      /mqlog calling ParseAndCheckPrice @price @item 
      /call ParseAndCheckPrice @price @item 
    } 
  } 
} 
/return
Also, is this even needed? I assume you have a #chat tell and /doevents chat in the macro.

Code: Select all

/if "@Param0"=="tell" {

onetimehero
a ghoul
a ghoul
Posts: 105
Joined: Fri Sep 05, 2003 2:42 pm

Grrrr.

Post by onetimehero » Sun Oct 26, 2003 5:25 pm

Code: Select all

      /varset l2 "$instr("the", "@cleanstr")" 
should have been

Code: Select all

      /varset l2 "$instr("the","@cleanstr")" 
Note to self: whitespace bad.

SMUUUURF HUUUUT.
Hmm. That's odd.