Store.lua suggestion for selling obsolete consumables
Posted: Tue Nov 01, 2011 4:16 am
Hi
I have been working on getting the bot to keep the bags clear of items it does not need to have in them, and just be more efficient, and have made some improvements, and a suggestion for a possible addition to the Store.lua file.
I have added a sell function to sell items that are too high a level for the bot to use. This situation generally happens when swapping to your lower level class, leaving items in your bag that are of no use until you level. I solved this with Rock5 help. See post http://www.solarstrike.net/phpBB3/viewt ... =21&t=3086
I then worked on removing the inventory items that were too low a level, such as when you gain a level and then stock up on higher level consumables (mana/health, quivers etc)
The low level items stay in my bags for potentially ever, as the bot keeps topping up consumables when the high level ones run low, never using/selling or dropping the lower level ones. There must be other people that have this issue, or is it just me?
So I started looking around at how the bot identified the level of consumable to buy, and it looks like the Store.lua file determines the "bestLevel" from the self.item table (generated from the vendors sell items.)
So once the bestLevel is determined, the Store.lu code then goes on to search(and total) the inventory for all the items that >= bestLevel and <= player.Level.
I added some code in to this inventory search loop to sell any item that is a consumable and does not fit into the above category, meaning it is too high or too low a level to use.
This is what the code was:
I then added a line making it this:
There could be other checks added in to check for level of item etc, but did put in a flimsy check to see if the person wanted to "AUTOSELL" items mainly to illustrate a possible profile option for this, like "INV_SELLUNUSABLE_ENABLE" or "INV_SELLOBSOLETE_ENABLE" or something similar could allow people to sell or not sell these unusable/obsolete consumables.
I have implemented it in the last 30mins and looks like it works as expected, but still have more testing to do. Servers have just shut down, so will have to test more tomorrow.
Keen to get some feedback on this. Is this useful to more than just me? How do others keep their bags clear of too high/low consumables?
I have been working on getting the bot to keep the bags clear of items it does not need to have in them, and just be more efficient, and have made some improvements, and a suggestion for a possible addition to the Store.lua file.
I have added a sell function to sell items that are too high a level for the bot to use. This situation generally happens when swapping to your lower level class, leaving items in your bag that are of no use until you level. I solved this with Rock5 help. See post http://www.solarstrike.net/phpBB3/viewt ... =21&t=3086
I then worked on removing the inventory items that were too low a level, such as when you gain a level and then stock up on higher level consumables (mana/health, quivers etc)
The low level items stay in my bags for potentially ever, as the bot keeps topping up consumables when the high level ones run low, never using/selling or dropping the lower level ones. There must be other people that have this issue, or is it just me?
So I started looking around at how the bot identified the level of consumable to buy, and it looks like the Store.lua file determines the "bestLevel" from the self.item table (generated from the vendors sell items.)
So once the bestLevel is determined, the Store.lu code then goes on to search(and total) the inventory for all the items that >= bestLevel and <= player.Level.
I added some code in to this inventory search loop to sell any item that is a consumable and does not fit into the above category, meaning it is too high or too low a level to use.
This is what the code was:
Code: Select all
-- Count number of better items in inventory
inventory:update();
local totalCount = 0;
for slot,item in pairs(inventory.BagSlot) do
local consumable = database.consumables[item.Id];
if item.Available and
consumable and
consumable.Type == type and
consumable.Level >= bestLevel and
consumable.Level <= player.Level then
totalCount = totalCount + item.ItemCount
end;
end;Code: Select all
-- Count number of better items in inventory
inventory:update();
local totalCount = 0;
for slot,item in pairs(inventory.BagSlot) do
local consumable = database.consumables[item.Id];
if item.Available and
consumable and
consumable.Type == type and
consumable.Level >= bestLevel and
consumable.Level <= player.Level then
totalCount = totalCount + item.ItemCount
elseif settings.profile.options.INV_AUTOSELL_ENABLE == true and
item.Available and
consumable and
consumable.Type == type then
item:use()
yrest(500) --not sure if rest is needed
end;
end;I have implemented it in the last 30mins and looks like it works as expected, but still have more testing to do. Servers have just shut down, so will have to test more tomorrow.
Keen to get some feedback on this. Is this useful to more than just me? How do others keep their bags clear of too high/low consumables?