Page 1 of 1

Problem with player:merchant

Posted: Mon Oct 04, 2010 3:58 pm
by Alkaiser
Abandoned Fortress

Code: Select all

<?xml version="1.0" encoding="utf-8"?><waypoints type="TRAVEL">
	<!-- #  1 --><waypoint x="13132" z="6821">
		player:merchant("Buruk Wright"); yrest(1000);
		sendMacro("CloseWindows()"); yrest(1000);
	</waypoint>
</waypoints>
After the bot purchases Ancestral Spirit Herbs and Elemental Spirit Stones, I always get this error: C:/micromacro/scripts/rom/classes/inventory.lua:412: attempt to compare number with nil

The only thing I have in my character profile related to the merchant function is this:

Code: Select all

		<option name="HEALING_POTION" value="20" />
		<option name="MANA_POTION" value="20" />
Any idea what's causing this?

Re: Problem with player:merchant

Posted: Tue Oct 05, 2010 1:24 am
by rock5
That's strange. Line 412 is right in the middle of the buying function. If it successfully buys the mana and hp potions then gets the error, then that implies that it tried to buy something else but failed. Are you sure you don't have any of the other consumables set in your profile?

Line 412 is;

Code: Select all

	if self:getItemCount(bestItem) < quantity then
I don't think it's possible for getItemCount() to return nil so I think quantity is nil. To narrow it down try adding the following before line 412 and see what gets printed when you get the error.

Code: Select all

if self:getItemCount(bestItem) == nil or quantity == nil then
    printf("Trying to buy type  %s\n",tostring(type))
    printf("getItemCount returned %s\n",tostring(self:getItemCount(bestItem)))
    printf("quantity returned %s\n",tostring(quantity ))
end
Hopefully I didn't make any syntax errors. :)

Re: Problem with player:merchant

Posted: Tue Oct 05, 2010 1:53 pm
by Alkaiser
Here's what happened:

Trying to buy type arrow_quiver
getItemCount returned 0
quantity returned nil

Hmmmmm... so why is it trying to buy arrows? I double checked my profile and the only thing related to arrows is this:

Code: Select all

<option name="RELOAD_AMMUNITION" value="false" />	<!-- false|arrow|thrown -->
I can't see how that would have anything to do with buying arrows, and even if it did, set to false.

EDIT:

Gah! If I add this to my profile...

Code: Select all

<option name="ARROW_QUIVER" value="0" />
...it works. So if that isn't in the profile, it assumes... what exactly?

Re: Problem with player:merchant

Posted: Tue Oct 05, 2010 3:08 pm
by Administrator
...it works. So if that isn't in the profile, it assumes... what exactly?
Someone made a typo that preventing it from defaulting to a proper setting. Thanks for the report.