What you are looking for, is a not so easy because you are looking at items of different types and you want to take usage level into account.
If you want to keep the code to trash these item simple, you can do this:
Lookup the ids in runes database and add them into a table and use a function like this:
Code: Select all
stuffToDelete = { } -- add ids here
function MyCleanBag(idsToDelete)
local name;
local k;
inventory:update()
for i, item in pairs(inventory.BagSlot) do
if item.Id ~= 0 and item.SlotNumber > 60 then
name = GetIdName(item.Id);
if name == nil then
name = "(no name found)";
end
-- delete items marked for delete
for j, element in pairs(idsToDelete) do
if item.Id == element then
print("dropping "..name);
item:delete()
end
end
end
end
end
...
MyCleanBag(stuffToDelete)
To find a group of items of a certain type you can use this function:
Code: Select all
function buildItemTableOfType(nameOfType)
local result = {};
local count = 1;
inventory:update()
for i, item in pairs(inventory.BagSlot) do
if item.Id ~= 0 then
if item:isType(nameOfType) then
result[count]=item;
count = count + 1;
end
end
end
return result;
end
function getIdsFrom(items)
local result = {};
local count = 1;
for j, element in pairs(items) do
result[count]=element.Id;
count = count + 1;
end
return result;
end
To delete all runes you can use something like this:
Code: Select all
items = buildItemTableOfType("Runes");
ids = getIdsFrom(items);
MyCleanBag(ids);
I'm not familiar with types, but I think there is something similar is available for "Potions" and "Ammo".
The functions above are parts of my scripts, so they should work.
This would be function that would filter items according to there usage level (this is untested):
Code: Select all
function filterItems(idsToFilter, requiredLevel)
local result = {};
local count = 1;
for j, element in pairs(idsToFilter) do
if requiredLevel > item.RequiredLvl then
result[count]=item.Id;
count = count + 1;
end
end
return result;
end
Then something like this could work to drop potions with a level below 41:
Code: Select all
potions = buildTableOfType("Potions");
potions = filterItems(potions, 41);
ids = getIdsFrom(potions);
MyCleanBag(ids);
Edit: tested the last functions myself and found, that I made a mistake. buildTableOfType returns ids, but you cannot determine any attributes from the id. So you must return an array of items and you need another helper function to collect ids from items.