First and foremost, thank you for your contribution. Know that all things I post following is not meant to bad mouth your macro at all, it's meant to teach you more if you're interested.
Missing a closing bracket.
Code:
Sub navigate
/echo trying to navigate to ${vendor}
/Target ${vendor}
/if (${Target.Distance}>15) {
/delay 1
/nav target
/echo Traveling to \ar ${vendor}
/delay 1
/while (${Navigation.Active}) {
/delay 1
}
/return
You start an if statement here, and I believe the if is meant to wrap around the while statement. But it never closes the if statements bracket.
I figure it's supposed to look like
Code:
Sub navigate
/echo trying to navigate to ${vendor}
/Target ${vendor}
/if (${Target.Distance}>15) {
/delay 1
/nav target
/echo Traveling to \ar ${vendor}
/delay 1
/while (${Navigation.Active}) {
/delay 1
}
}
/return
For the sake of speed when writing macros, it's also good to know if you didn't that you can have a /delay which takes a condition to stop early.
example.
Code:
/target id ${Spawn[npc ${vendor}].ID}
/delay 1s ${Target.ID} == ${Spawn[npc ${vendor}].ID}
This will target the spawn, and then wait for 1 second, or until the your targets ID if the ID of the spawn you wanted, whichever happens first. It's a good way to remove any unnecessary waiting a macro would do otherwise.
The code above also shows you how using a ${Spawn[search info]} can be used to get information about a specific spawn with more detail, so that you can then use that information without first targeting the NPC.
I want to show you have to use that for your navigation Sub because currently you're targeting the NPC without knowing where the player is in relation to the NPC. For macros you should not target things that the user cannot see, or would not otherwise be able to target manually.
Code:
Sub navigate
/echo trying to navigate to ${vendor}
/if (${Spawn[npc ${vendor}].Distance} > 15) {
/nav id ${Spawn[npc ${vendor}].ID}
/echo Traveling to \ar ${vendor}
/while (${Navigation.Active}) {
/delay 1
}
}
/return
That looks like a lot, but basically we're doing a spawn search to get the information for the spawn we're traveling to, but without first targeting it. You can research more about spawn searches here
https://redguides.com/docs/projects/macroquest/reference/general/spawn-search/
But since we no longer target the NPC in Sub navigate, we now need to do that in Sub interactWithVendor before we do the /click right target, so if you make the above change, make sure to also adjust for the change in this sub.
Moving down you have
/echo Gathering Vendor List and following that you start a for loop. In this for loop you have some odd indentation going on. I know that not everyone may know what is considered proper indentation, or might not even care if they use proper indentation. But it does help the readability of the code. I've taken a little bit of time to adjust the bracketing to get a better picture of how it's laid out in this section.
a couple of notes for this. In here you use multiple
/next v The rule of thumb when dealing with for loops in macros is that there should be only one /next for every /for, if you want to go to the next index in the loop in the middle of a loop you want to use
/continue and if you want to leave the for loop early you would use
/break.
So in the condition
/if (!${LItem}) { you will want to change that one to a
/continue
Last, you start an else statement, and before the closing bracket of that else portion of this loop you use
/next v, You should place this after the closing bracket for the else statement.
/varset itemDesc = ${Window[ItemDisplayWindow].Child[IDW_ItemDescriptionTabBox].Child[IDW_ItemInfo1].Text}
when using a varset, in a macro you do not need to use an
= unless you want the = to be part of the string in this case. This could be why you end up with a mismatch. Though I've not run it and added debugging code to verify.
Again I do hope this was helpful to you educationally, and you don't feel as though I were shaming you. I considered posting this to a PM but I also figured that other users might find the information useful if they too were interested in creating a macro. I've attached a copy of the macro after the adjustments I made and discussed here to hopefully give you the full picture.
Overall I think you did a good job, all the things I mentioned were simple things. I've always been a fan of "If it works, then I'm okay with it". But at the same time if it can work better, then no harm in that either :-)
Always good to see another member of the community contributing!