Page 1 of 1

Dangerous function AUTOSELL

Posted: Mon Mar 28, 2011 6:07 am
by Tsutomu
Well, maybe someone reported he's been sold his equipped item.
Why this happens?

1. If you have lootomatic enabled (and you have to - or some other addon doing same stuff) AND have the loot filter enabled.
How: For. ex. Last MOB you fight before going to NPC drops two stuff: small potion + chain mail of heavens.
You drop small potion (because of loot filter) but chainmail is taken before the potion is dropped.
Then an empty space is left before chainmail.
When you start autoselling, it comes to the empty space and apparently stops (closes seller window) but due to lag or bad loop (goes 1 more time after empty slot) it tries to sell that chainmail but in this time it sends it to be EQUIPPED. Then our expensive equipment is in our backpack waiting for next time to be sold (never - NEVER put that PURPLE option to sell items to NPC xD).
If you are smart and don't put PURPLE in autosel options, you are having another problem!
Unequipping item like happening to me (2 of them) Legguards and Main weapon 4100matk with some very very 200 times wors equipment :D may get you killed, or in best case slowing you down to a turtles speed. xD

2. If you use up all the potions that are in place after the autoloot_from. You can get the same situation as above. Unequipping items, and maybe even selling them to NPC if they are in rules set up for autosell. This should happen rarely but still can happen with significant % of possibility (being less than 1%, but still is worthwhile fixing).

-I can't say with certainty why this happens, didn't take a closer look at functions (or it has to do with updating item table - maybe should be forced before NPC?) or maybe some other thing is causing it. But it's a nasty little trip.
-Deleting all rules from loot filter should solve the first problem, but again we have the issue of used up potions after the autosell_from slot number.

Re: Dangerous function AUTOSELL

Posted: Mon Mar 28, 2011 6:23 am
by rock5
Autosell does not stop on empty slots. It shouldn't be doing what you're saying. Maybe we need to look at the code you are using to sell? But it should be simple, just player:merchant(...) unless you are doing something different.

Re: Dangerous function AUTOSELL

Posted: Mon Mar 28, 2011 6:31 am
by Tsutomu

Code: Select all

changeProfileOption("INV_AUTOSELL_FROMSLOT", 11);
changeProfileOption("INV_AUTOSELL_TOSLOT", 90);
changeProfileOption("INV_AUTOSELL_QUALITY", "white,green,blue");	
player:merchant("Shinobi");
then invite to party and load another waypoint file
(maybe put a player:rest(smthng_int); after merchant line?)

I was surprised to see my staff and leg guards in my BP but theyre purple so wouldn't sell anyway, but i have 2 white item could've been them :)
I tried testing it, htat's why i think it ends merchant window.
When i come to merchant i switch 1 item to the end and make a free space somwhere between AUTOSELL_TOSLOT and AUTOSELL_FROMSLOT. There were 2 items after the empty slot.
One was sold but second was left in my BP unsold.
Maybe i'm too far from merchant sometimes, but shouldn't be the case.

Re: Dangerous function AUTOSELL

Posted: Mon Mar 28, 2011 7:01 am
by rock5
I don't know. There is nothing there that should make it fail. Adding a pause afterward wont make any difference as it shouldn't leave the merchant function until it's finished. And you don't need to update the inventory because it's the first thing that is done in 'merchant'. Maybe, and I'm clutching at straws here, you have realy, really bad lag that slows it down and misses things or something like that?

Re: Dangerous function AUTOSELL

Posted: Mon Mar 28, 2011 7:30 am
by lisa
I think the key here is you are using the lootomatic addon to (drop) items, which means it loots everything and then dumps stuff you don't want. If you used the addon to only pick up the stuff you want then you wouldn't have the same issue.
The issue comes from the addon trying to get rid of items. Probably an idea to look into the addon itself to see where the issue is, I'd say it is probably to do with a rest between dropping items or lack of.

Re: Dangerous function AUTOSELL

Posted: Mon Mar 28, 2011 7:36 am
by Tsutomu
Yes, i intentionally loot everything then drop unwanted because people reported it working bad when selectively taking items. But i'll try for myself.

Anyway, if empty spaces have nothing to do with the thing then it doesn't matter what lootomatic does.

Re: Dangerous function AUTOSELL

Posted: Mon Mar 28, 2011 7:40 am
by lisa
Well you can get "ghost" spaces depending on how things are deleted. There is a trick to make bound materials unbound and the result is you click a space which looks empty but the item is actually in that spot. Not sure how the addon is removing the items from bag as I haven't look into the coding but I'd say the issue is coming from that.

Re: Dangerous function AUTOSELL

Posted: Mon Mar 28, 2011 7:50 am
by rock5
I use lootomatic and have never had problems with it and yes I 'loot all' then have it drop the items I don't want.

Re: Dangerous function AUTOSELL

Posted: Mon Mar 28, 2011 8:18 am
by Tsutomu
Okay, i've looked into files (classes) inventory and player .lua so i can say one more check should be added in autosell function in inventory.lua.

When it gets here:

Code: Select all

-- sell the item
if( sell_item == true ) then
hf_wesell = true;
slotitem:use();
end
it sells item after a lot of checks for different things, but doesn't check if store window is still open.
RoMScript("StoreFrame:IsVisible()") or smthng like that just before selling it:

Code: Select all

-- sell the item
if( sell_item == true ) then
if RoMScript("StoreFrame:IsVisible()") then
hf_wesell = true;
slotitem:use();
end
end
Would disable any kind of unwanted equiping of bkpk items, a needed check for proofing the actions 100% of any mistake.
Easy i think to fix it, i'll use it in my instance of RomBot but might be good to include in new release?

I think this will solve all the issues about that whatever is the reason.

Re: Dangerous function AUTOSELL

Posted: Mon Mar 28, 2011 8:30 am
by rock5
Yes that could be added.

Let us know how well it fixed your problem.

I still leaves the question, why was it failing for you? Was it definately switching equipment while at the merchant or is it possible it got switch earlier when maybe something else was trying to use something in the inventory and accidentally equiped an item. Do you have any other code in your waypoint (or profile) that does anything with the inventory?

Well at least you wont loose items anymore (hopefully).

Re: Dangerous function AUTOSELL

Posted: Mon Mar 28, 2011 8:38 am
by Tsutomu
I don't think so, have nothing other that manages items in any way in my files, except lootomatic addon for RoM but i doubt it caused it, should never use the items that i take (those were the ones out of loot filter - keepable).
I'll let you know how it works, i think it'll solve some obscure cases why this happens.
Hm what i thought is reopening the store window again if checks unopen.
That way we'll end up selling the items if store window was closed by a strange dark force i'm yet unaware of :D

Code: Select all

-- sell the item
if( sell_item == true ) then
 if (not RoMScript("StoreFrame:IsVisible()")) then
  "function to open store frame";
  if RoMScript("StoreFrame:IsVisible()") then
   hf_wesell = true;
   slotitem:use();
  end
 else
 hf_wesell = true;
 slotitem:use();
 end
end

Re: Dangerous function AUTOSELL

Posted: Mon Mar 28, 2011 8:47 am
by Tsutomu
Sry 4 dblposting

Actually we can't open store again, we don't have in a global val the name of the NPC (or i'm mistaken).
So i'l just go with previous version for skipping autosell if store frame not visible, without reopening the store.

note:
player:openStore(_npcname, _option) - can''t know which NPC was that we used in player:merchant();

Re: Dangerous function AUTOSELL

Posted: Mon Mar 28, 2011 12:15 pm
by Tsutomu
tripleposting :S

The CODE above i changed in inventory.lua is working great, no more problems of anykind so far (couple of hours working - 15-20 times tested automatically ingame).

Re: Dangerous function AUTOSELL

Posted: Mon Mar 28, 2011 6:47 pm
by rock5
When it used to fail, did the shop initially open? Or was the problem that the shop didn't open in the first place?

Because if the shop didn't open in the first place we could put the StoreFrame check at the beginning of the autosell function (that's more logical) to avoid running all the code below it if the frame isn't even open.

Re: Dangerous function AUTOSELL

Posted: Mon Mar 28, 2011 7:00 pm
by rock5
Another idea occured to me. The only code that could interrupt the mechant function is a registered timer. Have you set up any registered timers with registerTimer function?

Re: Dangerous function AUTOSELL

Posted: Tue Mar 29, 2011 1:49 am
by Tsutomu
rock5 wrote:Another idea occured to me. The only code that could interrupt the mechant function is a registered timer. Have you set up any registered timers with registerTimer function?
No i didn't register any timers at that point, later in the instance they are, and unregistered before leaving it.

Shop did open initially, but it occured to me that sometimes in play shop closes itself mysteriously after leaving it open for a bit longer time. Usually i'm done with shop in 10 sec, sometimes if it takes longer the frame just disappears.

It also might be of a lag, but anyway fixed with the code checking for open shop frame just before selling with slotitem:use();
Whatever is the cause i think it's good to get it secured of unwanted behaviour and spare people of any possible trouble.

Re: Dangerous function AUTOSELL

Posted: Tue Mar 29, 2011 3:30 am
by rock5
There really isn't any reason why it would close the shop prematurely but it wont hurt to add your changes. I'll add a 'break' as well because we don't need it to continue if the store isn't open.

Code: Select all

			-- sell the item
			if( sell_item == true ) then
				if RoMScript("StoreFrame:IsVisible()") then
					hf_wesell = true;
					slotitem:use();
				else
					break
				end
			end

Re: Dangerous function AUTOSELL

Posted: Tue Mar 29, 2011 8:19 am
by Tsutomu
yes, i forgot about that. :) break is needed too.