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
-
driftinsupra
- Official loudmouth

- Posts: 212
- Joined: Tue Jan 28, 2003 9:25 pm
Post
by driftinsupra » Sun Dec 14, 2003 3:26 pm
ok if anyone has messed around with the bazaar plugin you will find that when you issue a $bazaar(n,name) it does not return a clean name but instead something like Words of Abatement(1) where the (1) is how many of that item the merchant has. The problem is when I go to buy that item I cant target Words of Abatement(1) sine it isnt a real item. I accidently bought like 2k worth in crap because of this. If anyone knows what I can do to clean out those last numbers and stuff I would really appreciate it.
-
ml2517
- a grimling bloodguard

- Posts: 1216
- Joined: Wed Nov 12, 2003 1:12 am
Post
by ml2517 » Sun Dec 14, 2003 3:54 pm
This should do what you want:
Code: Select all
#turbo
Sub Main
/declare ItemName global
/declare PartialName global
/declare Token global
/varset ItemName "Words of Abatement(1)"
/varset Token $instr("(","@ItemName")
/varset PartialName "$left(@Token,"@ItemName")"
/echo @PartialName
/return
-
driftinsupra
- Official loudmouth

- Posts: 212
- Joined: Tue Jan 28, 2003 9:25 pm
Post
by driftinsupra » Sun Dec 14, 2003 4:09 pm
You are my new best friend. I didnt even know that $instr thing existed. Thanks again!!!
-
driftinsupra
- Official loudmouth

- Posts: 212
- Joined: Tue Jan 28, 2003 9:25 pm
Post
by driftinsupra » Sun Dec 14, 2003 4:25 pm
ok I got a new problem now
/varset theitem $bazaar(@l1,name)
this I just added to the findcheapest macro that DKAA used as an example for his plugin. the problem is when I do a /echo for the variable I keep getting an UNDFINED LOCAL in the mq chat window. WHAT is this crap? I do a /echo $bazaar(5,name) just to see if it works and it does it just wont work in the script for some reason.
-
ml2517
- a grimling bloodguard

- Posts: 1216
- Joined: Wed Nov 12, 2003 1:12 am
Post
by ml2517 » Sun Dec 14, 2003 4:30 pm
Did you:
Code: Select all
[color=red]/declare theitem local[/color]
/varset theitem $bazaar(@l1,name)
?
-
ml2517
- a grimling bloodguard

- Posts: 1216
- Joined: Wed Nov 12, 2003 1:12 am
Post
by ml2517 » Sun Dec 14, 2003 4:33 pm
Post the full macro.
-
driftinsupra
- Official loudmouth

- Posts: 212
- Joined: Tue Jan 28, 2003 9:25 pm
Post
by driftinsupra » Sun Dec 14, 2003 4:35 pm
this is the beginning of the script.
Code: Select all
#include routines2.mac
#turbo
sub main
/declare file global
/declare isle global
/declare counter local
/declare l1 local
/declare traderid local
/declare price local
/declare curmoney local
/declare newmoney local
/declare profit local
/declare item local
/declare theitem global
/declare Token global
/varset file C:\macroquest2\release\macros\newini.ini
/varset counter 1
:mainloop
/echo searching for @Param0
/bzsrch race any class any price 0 @Param1 "@Param0"
| is request done?
:loop
/delay 1
/if "$bazaar()"=="FALSE" /goto :loop
/if n $bazaar(count)==0 {
/echo @Param0 not found, exiting
/return
}
} else {
/echo found $bazaar(count) items
}
/varset price $bazaar(0,price)
/varset traderid $bazaar(0,trader)
/if n $bazaar(count)>1 {
/for l1 1 to $calc($bazaar(count)-1)
/echo @l1 price $bazaar(@l1,price)
/if n @price>$bazaar(@l1,price) {
/varset price $bazaar(@l1,price)
/varset traderid $bazaar(@l1,trader)
/varset theitem $bazaar(@l1,name)
}
/next l1
}
/echo @theitem
/varset Token $instr("(","@theitem")
/varset item $left(@Token,"@theitem")
/echo is @item
-
driftinsupra
- Official loudmouth

- Posts: 212
- Joined: Tue Jan 28, 2003 9:25 pm
Post
by driftinsupra » Sun Dec 14, 2003 4:36 pm
its probably something ragingly stupid but I cant find it
-
ml2517
- a grimling bloodguard

- Posts: 1216
- Joined: Wed Nov 12, 2003 1:12 am
Post
by ml2517 » Sun Dec 14, 2003 4:43 pm
One thing I see is that you didn't put the quotes here:
Code: Select all
/varset item [color=red]"[/color]$left(@Token,"@theitem")[color=red]"[/color]
-
driftinsupra
- Official loudmouth

- Posts: 212
- Joined: Tue Jan 28, 2003 9:25 pm
Post
by driftinsupra » Sun Dec 14, 2003 4:45 pm
I will change that but the problem is that first /echo I get UNDEFINED LOCAL. The /varset theitem $bazaar(@l1,name) line isnt setting theitem to anything
-
blueninja
- a grimling bloodguard

- Posts: 541
- Joined: Thu Aug 28, 2003 7:03 am
- Location: Göteborg, Sweden
Post
by blueninja » Sun Dec 14, 2003 4:47 pm
The undefined thing means that the variable was never set. Are you sure the /varset line is actually executed? Try putting an echo in the inner /if block to make sure. For example if you only get one item you would never fall into the outermost /if block and the varset line would never be reached. Set theitem to "$bazaar(0,name)" before the /if block.
One more thing, put $bazaar(@l1,name) in quotes, if it contains spaces the variable will only be set to the first word.
-
ml2517
- a grimling bloodguard

- Posts: 1216
- Joined: Wed Nov 12, 2003 1:12 am
Post
by ml2517 » Sun Dec 14, 2003 4:51 pm
Maybe try:
Code: Select all
/varset theitem [color=red]"[/color]$bazaar(@l1,name)[color=red]"[/color]
or
/varset theitem [color=red]"[/color]$bazaar(@l1,[color=red]"[/color]name[color=red]"[/color])[color=red]"[/color]
-
driftinsupra
- Official loudmouth

- Posts: 212
- Joined: Tue Jan 28, 2003 9:25 pm
Post
by driftinsupra » Sun Dec 14, 2003 4:52 pm
woot! I got it! The /if staement doesnt actually get executed unless the first item in the list isnt the cheapest or something and since I was only looking for items from 0 to 1pp it didnt go into the if. Thanks for the help guys
-
wassup
- Official Guardian and Writer of TFM

- Posts: 1487
- Joined: Sat Oct 26, 2002 5:15 pm
Post
by wassup » Sun Dec 14, 2003 6:31 pm
I posted a change to the findcheapest macro in the bzsrch plugin thread.
I tried yours but that movement stuff just didn;t work. I cut out the movement and just use the golden path to find the trader myself.
Here are the changes I made to your macro, should be obvious where the code is inserted/changed:
Code: Select all
/declare length local
/varset length $strlen("@itemSrch")
/if n $bazaar(count)>1 {
/for l1 0 to $calc($bazaar(count)-1)
/if "@itemSrch"=="$left(@length,"$bazaar(@l1,name)")" {
/varset price $bazaar(@l1,price)
/varset traderid $bazaar(@l1,trader)
/if n @price<=@iniPrice {
/echo Found buyable @itemSrch on $spawn(@traderid,name)
/target id @traderid
/face
/endmacro
}
}
/next l1
}