Page 1 of 1

Error while trying to use HP potion

Posted: Sun Sep 23, 2012 3:13 pm
by muratiks
rombot give this error when try to use hp potions. i have potions in both bags.

Image

Re: Error while trying to use HP potion

Posted: Sun Sep 23, 2012 3:35 pm
by rock5
Line numbers don't match up. Line 75 is

Code: Select all

	if not self.InUse then
No deltatime there. So maybe you have a corrupt rombot installation. Try Lisas sig instructions.
Can't get bot to work? follow these instructions before posting, thank you.
1. SVN update micromacro/scripts/rom folder
2. SVN revert micromacro/scripts/rom folder
3. delete Runes of Magic/Interface/Addons/ingamefunctions folder
4. copy micromacro/scripts/rom/devtools/ingamefunctions folder to Runes of Magic/Interface/Addons folder
5. restart game

Re: Error while trying to use HP potion

Posted: Sun Sep 23, 2012 3:47 pm
by BillDoorNZ
hmm...thats an interesting one...

the code starting from line 75 (in my version at least) is :

Code: Select all

	if not self.InUse then
		if ( self.CoolDownTime > 0 and self.LastTimeUsed ~= 0 and
		( deltaTime( getTime(), self.LastTimeUsed ) / 1000 ) < self.CoolDownTime ) then -- Item is on CoolDown we can't use it
			canUse = false;
			reason = "Cooldown";
		end;
	else -- Item is in use, locked, we can't use it
		reason = "In use";
		canUse = false;
	end;

	if ( canUse ) then
		RoMScript("UseBagItem("..self.BagId..")");
		self.LastTimeUsed = getTime();
		yrest( 500 ); -- give time for server to respond with new item count
	else
		cprintf( cli.yellow, "DEBUG - Cannot use Item %s\t BagId: #%s ItemCount: %s\treason: %s\n", self.Name, self.BagId, self.ItemCount, reason );
		logMessage( sprintf( "DEBUG - Cannot use Item %s\t BagId: #%s ItemCount: %s\treason: %s\n", self.Name, self.BagId, self.ItemCount, reason ) );
	end;
obviously the error is on line 76 (the next line) where it is calling deltaTime(getTime(), self.LastTimeUsed)....and the LastTimeUsed must be nil. Not sure how that is happening, but if it is the first time the item is used, then that could be causing the problem - but only if the item is flagged as InUse as specified on the first line:

Code: Select all

	if not self.InUse then
So...did you manually use the potion while the bot was fighting? Or were you moving the item?

hmmm...after re-reading the code, I don't see how the LastTimeUsed value can ever be nil. It is set to 0 when the object is constructed and only ever changed in the CInventoryItem:use() function.

Does this happen every time? or was it a one-off occurrence?

Re: Error while trying to use HP potion

Posted: Sun Sep 23, 2012 3:58 pm
by muratiks
i did everything u said and got error same propblem

Image

Re: Error while trying to use HP potion

Posted: Sun Sep 23, 2012 4:15 pm
by muratiks
BillDoorNZ wrote:So...did you manually use the potion while the bot was fighting? Or were you moving the item?
i try and same error.

also bot doesnt start if hp lower than %90

<option name="HP_LOW_POTION" value="90" />

it happens everytime

Rompvp private server

Re: Error while trying to use HP potion

Posted: Sun Sep 23, 2012 4:45 pm
by BillDoorNZ
very odd.

can you change the code in inventoryitem.lua at line 75 to:

Code: Select all

	if not self.InUse then
		printf("Item InUse: "..tostring(self.Name).." slot:"..tostring(self.SlotNumber).." bag:"..tostring(self.BagId).." LastTimeUsed:"..tostring(self.LastTimeUsed).."\n");
		if ( self.CoolDownTime > 0 and self.LastTimeUsed ~= 0 and
so, really, just adding that printf line in between the other two. This will probably spam you with lots of prints, but may point to the problem a bit more..or not :)

Re: Error while trying to use HP potion

Posted: Sun Sep 23, 2012 4:58 pm
by muratiks
Image

Re: Error while trying to use HP potion

Posted: Sun Sep 23, 2012 5:27 pm
by BillDoorNZ
and you definitely went through the steps Rock outlined?
rock5 wrote:Line numbers don't match up. Line 75 is

Code: Select all

	if not self.InUse then
No deltatime there. So maybe you have a corrupt rombot installation. Try Lisas sig instructions.
Can't get bot to work? follow these instructions before posting, thank you.
1. SVN update micromacro/scripts/rom folder
2. SVN revert micromacro/scripts/rom folder
3. delete Runes of Magic/Interface/Addons/ingamefunctions folder
4. copy micromacro/scripts/rom/devtools/ingamefunctions folder to Runes of Magic/Interface/Addons folder
5. restart game
I'm asking, as I can't see any way that LastTimeUsed can be nil given the latest code. I thought the private servers ran off a different version of the bot? or an older version?

one thing you could try (to make it work for now) is changing the code to:

Code: Select all

	-- If the item can't be used now we should be able to set a timer or something like that to recall this function and check again...
	if not self.InUse then
		if ( self.CoolDownTime > 0 and self.LastTimeUsed ~= 0 and (self.LastTime)
		( deltaTime( getTime(), self.LastTimeUsed ) / 1000 ) < self.CoolDownTime ) then -- Item is on CoolDown we can't use it
(removing the debug line I gave you at the same time).

This may end up breaking things elsewhere, I'm not sure.

Re: Error while trying to use HP potion

Posted: Sun Sep 23, 2012 7:32 pm
by lisa
BillDoorNZ wrote:and you definitely went through the steps Rock outlined?
rock5 wrote:Line numbers don't match up. Line 75 is

Code: Select all

	if not self.InUse then
No deltatime there. So maybe you have a corrupt rombot installation. Try Lisas sig instructions.
Can't get bot to work? follow these instructions before posting, thank you.
1. SVN update micromacro/scripts/rom folder
2. SVN revert micromacro/scripts/rom folder
3. delete Runes of Magic/Interface/Addons/ingamefunctions folder
4. copy micromacro/scripts/rom/devtools/ingamefunctions folder to Runes of Magic/Interface/Addons folder
5. restart game
Any time an item is defined with the item class the item.LastTimeUsed is defined as 0, the only way for it to be nil is if the bot is not the default bot and changes have been made or perhaps downloaded from another site where they made changes which obviously broke the bot, happened far to many times.

I guess there is 1 other possibility, getTime() is returning nil but in that line of code the getTime() isn't returning nil, only the LastTimeUsed is.

Just do a SVN update and SVN revert to the bot folder.

Re: Error while trying to use HP potion

Posted: Mon Sep 24, 2012 4:00 am
by muratiks
i delete everything and download rombot update with svn and i have new error

Image

rompvp private server version 5.0.2.2565

Re: Error while trying to use HP potion

Posted: Mon Sep 24, 2012 4:11 am
by lisa
That already looks better to me, something to note it says you are using micromacro v1.0
Current version is
MicroMacro v1.02 Beta 4

So yeah you need to update micromacro aswell =)

I should have looked at the join date, yeah a lot has changed since you last used the bot, so starting fresh is a very good idea. I doubt any of your old profiles would work, maybe even old waypoints might have an issue.

Re: Error while trying to use HP potion

Posted: Mon Sep 24, 2012 4:23 am
by muratiks
thanks all.

its working now :P