Page 1 of 1

Error when checking inventory

Posted: Tue Jan 26, 2010 6:04 pm
by giantenigma
Whenever the bot tries to run this code, it generates an error (see below). Basically, with this code, I am checking my inventory every time I kill an enemy to check to see if it is full. I don't entirely know why the error is ocurring. Should I change "50" to 50, or is there anything else I need to change?


Code: Select all

<onLeaveCombat><![CDATA[
		-- Additional Lua code to execute after killing an enemy
		if(sendMacro("GetBagCount();") > "50") then
			inventory:update();
		end
		if(sendMacro("GetBagCount();") == "60") then
			loadPaths("boarstomerch.xml");
		end	
	]]>
	</onLeaveCombat>

Code: Select all

Tue Jan 26 17:37:55 2010 : ...micromacro/scripts/rom/classes/player.lua:804: Error in your profile: onLeaveCombat error: [string "..."]:3: attempt to compare string with number
Tue Jan 26 17:37:55 2010 : Execution error: Runtime error
Thanks in advance!

Re: Error when checking inventory

Posted: Tue Jan 26, 2010 6:25 pm
by TopaZ
giantenigma wrote:Whenever the bot tries to run this code, it generates an error (see below). Basically, with this code, I am checking my inventory every time I kill an enemy to check to see if it is full. I don't entirely know why the error is ocurring. Should I change "50" to 50, or is there anything else I need to change?


Code: Select all

<onLeaveCombat><![CDATA[
		-- Additional Lua code to execute after killing an enemy
		if(sendMacro("GetBagCount();") > "50") then
			inventory:update();
		end
		if(sendMacro("GetBagCount();") == "60") then
			loadPaths("boarstomerch.xml");
		end	
	]]>
	</onLeaveCombat>

Code: Select all

Tue Jan 26 17:37:55 2010 : ...micromacro/scripts/rom/classes/player.lua:804: Error in your profile: onLeaveCombat error: [string "..."]:3: attempt to compare string with number
Tue Jan 26 17:37:55 2010 : Execution error: Runtime error
Thanks in advance!
I am not good at programming but this code will must work.

Code: Select all

<onLeaveCombat>
		-- Additional Lua code to execute after killing an enemy
		if(sendMacro("GetBagCount();") > 50) then
			inventory:update();
		end
		if(sendMacro("GetBagCount();") == 60) then
			loadPaths("boarstomerch.xml");
		end	
</onLeaveCombat>

Re: Error when checking inventory

Posted: Sat Jan 30, 2010 9:11 am
by d003232
There could always be, that you get a wrong value back from the "sendMacro" function. e.g. if you press/hold a key while the bot try to press the macro key. So you should be prepared for getting back all kind of values string/nil/numbers and check internaly if it's a valid value.