? A way to know a merchant's selling price ?

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

Miseaujeu
a lesser mummy
a lesser mummy
Posts: 32
Joined: Mon Nov 24, 2003 6:25 pm

? A way to know a merchant's selling price ?

Post by Miseaujeu » Mon Jan 26, 2004 6:04 pm

Fake-o code

Code: Select all

   /selectitem LETTUCE merchant
   /delay 1s
   /varset COST_OF_ITEM $merchant(LETTUCE,cost) 
That's essentially what I would like -- to be able to drop the cost of the item into a variable. What format? Uh ... it could even be 4 variables for all I care ( PP, GP, SP, CP ) or an array for the different kinds of pieces......

lil` help :wink:

-M

User avatar
dont_know_at_all
Developer
Developer
Posts: 5450
Joined: Sun Dec 01, 2002 4:15 am
Location: Florida, USA
Contact:

Post by dont_know_at_all » Mon Jan 26, 2004 7:21 pm

Write an event to parse what the merchant says.

Miseaujeu
a lesser mummy
a lesser mummy
Posts: 32
Joined: Mon Nov 24, 2003 6:25 pm

riiight ... parsing....

Post by Miseaujeu » Tue Jan 27, 2004 4:34 pm

Wevil Doughbeard tells you, 'That'll be 6 platinum 3 gold 7 silver 2 copper for the iceball'.

Code: Select all

#Event VendorPrice " tells you, 'That'll be "
.
.
.

Sub Event_VendorPrice(merchtext)
If "$arg(2, @merchtext)"=="platinum" PlatPieces = $arg(1, @merchtext)
If "$arg(2, @merchtext)"=="gold" GoldPieces = $arg(1, @merchtext)
If "$arg(2, @merchtext)"=="silver" SilverPieces = $arg(1, @merchtext)
If "$arg(2, @merchtext)"=="copper" CopperPieces = $arg(1, @merchtext)
/return
So, in this example PlatPieces would be set to 6 and GoldPieces, SilverPieces and CopperPieces wouldn't be changed.... right?

-M

Miseaujeu
a lesser mummy
a lesser mummy
Posts: 32
Joined: Mon Nov 24, 2003 6:25 pm

/beats head against wall

Post by Miseaujeu » Fri Jan 30, 2004 12:41 pm

Alright ... have made quite a bit of headway on this macro -- but I'm getting tripped up back in this spot once again. Here is the "applicable" code as I see it:

Wevil Doughbeard tells you, 'That'll be 6 platinum 3 gold 7 silver 2 copper for the iceball'.
Wevil Doughbeard tells you, 'That'll be 2 platinum 1 gold 3 copper for the Tasty Lettuce'.

Code: Select all

#Event VendorPrice " tells you, 'That'll be "

	/declare PlatPieces Global
	/declare GoldPieces Global
        ....etc..
	/declare merchtext Global

	/varset PlatPieces 0
	/varset GoldPieces 0
       ....etc...
.
.
/selectitem "Tasty Lettuce" merchant
/delay 1s
/if "$selecteditem()"=="Tasty Lettuce" {
/echo Vendor Has It!
	[color=yellow]/doevents[/color]
	/echo after /doevents we now have PP=@PlatPieces, GP=@GoldPieces, SP=@SilverPieces and CP=@CopperPieces
	/varset Price @PlatPieces     [color=yellow] | I suspect the trouble is here with the /varset or /varcat[/color]
	/varcat Price @GoldPieces
	/varcat Price @SilverPieces
	/varcat Price @CopperPieces
	/echo @Price > 2102 ?       [color=yellow]| 2102 = 2pp, 1gp, 0sp, 2cp[/color]
	/if @Price>2102 {
.
.
.
Sub Event_VendorPrice(merchtext)
[color=yellow]/if "@merchtext"~~"Tasty Lettuce" {[/color]
/If $arg(8,"@merchtext")=="platinum" {          [color=yellow] if 8th word in Merchtext is [b]platinum[/b] then...[/color]
	/varset PlatPieces $arg(7,"@merchtext")
	/If $arg(10,"@merchtext")=="gold" {
		/varset GoldPieces $arg(9,"@merchext")
		} else {
		/varset GoldPieces 0
	}
	/If $arg(12,"@merchtext")=="silver" {
		/varset SilverPieces $arg(11,"@merchtext")
		} else {
		/varset SilverPieces 0
	}
	/If $arg(14,"@merchtext")=="copper" {
		/varset CopperPieces $arg(13,"@merchtext")
		} else { 
		/varset CopperPieces 0
	}
/goto :end
}
So, it searches a merchant for the item ... when the merch says how much for it that sets off the event which IF IT'S THE CORRECT ITEM should parse out the $$. However with the echo line /echo after /doevents we now have PP=@PlatPieces, GP=@GoldPieces, SP=@SilverPieces and CP=@CopperPieces I get things line PP=2 GP= SP=9 CP=1! The PP tend to be correct ... but GP is EMPTY! and then the rest are incorrect.
Because of this I think it must be the /varset or /varcat -- but I'm also sorta suspicious of the /doevents. Since the Merch had already told me about the iceball in the above example -- I wonder if somehow that $$ is getting parsed and runing the data.
Anything that sticks out here?

-M

User avatar
dont_know_at_all
Developer
Developer
Posts: 5450
Joined: Sun Dec 01, 2002 4:15 am
Location: Florida, USA
Contact:

Post by dont_know_at_all » Fri Jan 30, 2004 1:00 pm

loop

Miseaujeu
a lesser mummy
a lesser mummy
Posts: 32
Joined: Mon Nov 24, 2003 6:25 pm

Post by Miseaujeu » Fri Jan 30, 2004 1:53 pm

...back from lunch.


Hmmm, "Loop".

as in, "Hey, you're MISSING a loop!"

or, "obviously, the event is causing a loop."

Or, "I like fruit-loops"

Please, can I have another nudge :) ?

-M

User avatar
blueninja
a grimling bloodguard
a grimling bloodguard
Posts: 541
Joined: Thu Aug 28, 2003 7:03 am
Location: Göteborg, Sweden

Post by blueninja » Fri Jan 30, 2004 2:11 pm

My guess is:
..as in, don't use fixed positions for your $arg's, loop through them all (well not all but at least the middle few) and check each of them for all the coin types.

For example, say you're shopping from boomba the big in freeport, his name is 3 words long wich would change the offset of the words. Also prices that have a price of 0 for a certain coin would be screwed up (for expample if something costs 8gold 9copper).

Be careful that you don't catch the cases where those selected words are in other parts of the message (for example: "Joe Gold tells you, that'll be 41 gold 19 silver for the Platinum bar").

Miseaujeu
a lesser mummy
a lesser mummy
Posts: 32
Joined: Mon Nov 24, 2003 6:25 pm

myyupp

Post by Miseaujeu » Fri Jan 30, 2004 2:23 pm

Code: Select all

Sub Event_VendorPrice(merchtext)
/if "@merchtext"~~"Tasty Lettuce" {

/echo $arg(8,"@merchtext")
/echo $arg(10,"@merchtext")
/echo $arg(12,"@merchtext")

/If $arg(8,"@merchtext")=="platinum" {
	/varset PlatPieces $arg(7,"@merchtext")
	[color=yellow]/echo here I'm /varset PlatPieces $arg(7,"@merchtext")[/color]
	/If $arg(10,"@merchtext")=="gold" {
		/varset GoldPieces $arg(9,"@merchext")
		[color=yellow]/echo here I'm /varset GoldPieces $arg(9,"@merchtext")[/color]
		} else {
		/varset GoldPieces 0
	}
	/If $arg(12,"@merchtext")=="silver" {
		/varset SilverPieces $arg(11,"@merchtext")
		[color=yellow]/echo here I'm /varset SilverPieces $arg(11,"@merchtext")[/color]
		} else {
		/varset SilverPieces 0
	}
	/If $arg(14,"@merchtext")=="copper" {
		/varset CopperPieces $arg(13,"@merchtext")
		[color=yellow]/echo here I'm /varset CopperPieces $arg(13,"@merchtext")[/color]
		} else { 
		/varset CopperPieces 0
	}
/goto :end
}
/If $arg(8,"@merchtext")=="gold" {
	/varset PlatPieces 0
	/varset GoldPieces "$arg(7,"@merchtext")"
	[color=yellow]/echo GoldPieces = @GoldPieces[/color]
	/If "$arg(10,"@merchtext")"=="silver" {
		/varset SilverPieces "$arg(9,"@merchtext")"
[color=yellow]		/echo SilverPieces = @SilverPieces[/color]
		} else {
		/varset SilverPieces 0
[color=yellow]		/echo SilverPieces = @SilverPieces[/color]
	}
	/If "$arg(12,"@merchtext")"=="copper" {
		/varset CopperPieces "$arg(1,"@merchtext")"
[color=yellow]		/echo CopperPieces = @CopperPieces[/color]
		} else {
		/varset CopperPieces 0
		/echo CopperPieces = @CopperPieces
	}
}
/If "$arg(8,"@merchtext")"=="silver" {
	/varset PlatPieces 0
	/varset GoldPieces 0
	/varset SilverPieces $arg(7, "@merchtext")

	/If "$arg(10,"@merchtext")"=="copper" {
		/varset CopperPieces "$arg(9, "@merchtext")"
		} else {
		/varset CopperPieces 0
	}
}
/If "$arg(8,"@merchtext")"=="copper" {
	/varset PlatPieces 0
	/varset GoldPieces 0
	/varset SilverPieces 0
	/varset CopperPieces "$arg(7, "@merchtext")"
	}
}
:end
/return
Hmm ... that might be something --- but I've been very much AT KEYBOARD for this and have been careful to only check on vendors that have two names. And yes, I have been watching for those Gold 'n Silver probs in people's names

In the above code I've also shown the /echo GoldPieces = @GoldPieces. Irritatingly these would ECHO CORRECT! But, then the assigned variables would have faulty data.

Thanks ..... but I don't think that's all of it.

-M

Miseaujeu
a lesser mummy
a lesser mummy
Posts: 32
Joined: Mon Nov 24, 2003 6:25 pm

woot!

Post by Miseaujeu » Fri Jan 30, 2004 8:08 pm

Huzzah! It works .... and it wasn't all due to a (*&#(*& TYPO!

Code: Select all

/If $arg(8,"@merchtext")=="platinum" { 
   /varset PlatPieces $arg(7,"@merchtext") 
   /echo here I'm /varset PlatPieces $arg(7,"@merchtext") 
   /If $arg(10,"@merchtext")=="gold" { 
      /varset GoldPieces $arg(9,"[color=red][size=200]@merchext")[/size][/color] 
      /echo here I'm /varset GoldPieces $arg(9,"@merchtext") 
      } else { 
      /varset GoldPieces 0 
How's that for a sore thumb?

Anyway ... happy now :D

Miseaujeu
a lesser mummy
a lesser mummy
Posts: 32
Joined: Mon Nov 24, 2003 6:25 pm

/em starts choking on own rage....

Post by Miseaujeu » Sat Jan 31, 2004 12:16 am

well ... it's been working quite well this evening ... but I've found some "bugs" ... but I don't know why they're bugs.

remeber this ?

Code: Select all

/echo after /doevents we now have PP=@PlatPieces, GP=@GoldPieces, SP=@SilverPieces and CP=@CopperPieces
	/varset Price @PlatPieces
	/varcat Price @GoldPieces
	/varcat Price @SilverPieces
	/varcat Price @CopperPieces
this would then have the "Price" of an item in copper pieces. (I.E. something that was 1pp would show as 1000.)

the next bit is this :

Code: Select all

/if @Price>25000
/echo "Tasty Lettuce" cost @Price!  Tha's too much!
example : Wevil Doughbeard tells you, 'That'll be 2 platinum 1 gold 3 copper for the Tasty Lettuce'.
k ... so the parser would break this down to 2103 and then do the check:
2103 > 25000 ? no ... it's Cheaper! soooo buy it!

Here comes the problem.... I've had several instances such as the following.

Vendor So'n'So tells you, 'That'll be 140 platinum 7 gold for the shiny object'.
k ... so the parser breaks it down to 140700 and then the check:
140700 > 25000 ? YES --- therefore /echo "shiny object" cost 140700! Tha's too much!

but, then it tries to buy it anyway. Weeeiiiirrrrd.

So, I figured that it had to be something along the lines of @Price not being considered a number ... mebbie thought of as a string or something?
But, even changing the code to the following didn't do the trick:

Code: Select all

/if $int(@Price)>$int($ini(dive_stuff.ini,BUDGET,@Counter))
But then I thought that mebbie there was a problem with the number 140700 being larger than 65000 ( or whatever ther max. int is in this ) --- so ... then I should convert it to a float or something ? .... and now I just don't know.

Hints or straightforward explainations would be lovely :wink:

-M

Miseaujeu
a lesser mummy
a lesser mummy
Posts: 32
Joined: Mon Nov 24, 2003 6:25 pm

/cheer

Post by Miseaujeu » Sat Jan 31, 2004 12:50 am

Another huge THANKS going out to DKAA for the answer to this one...

Code: Select all

/if [color=red][size=200]n[/size][/color] $int(@Price)>$int($ini(dive_stuff.ini,BUDGET,@Counter))
...has to be a numeric compare.

-M