Cleanbag userfunction 2.5

Additional botting resources. Addons may be either for the game itself or for the RoM bot.
Forum rules
Only post additional bot resources here. Please do not ask unrelated questions.
Message
Author
User avatar
botje
Posts: 656
Joined: Wed Oct 27, 2010 7:17 am

Cleanbag userfunction 2.5

#1 Post by botje » Thu Aug 18, 2011 9:53 am

Finally done with it, thanx to rock and lisa for showing me most (if not all) of the workings xd

just thought i would share it.

Code: Select all

-- sell prize = value which drops all below it
-- rarity = / 0 = white / 1 = green / 2 = blue / 3 = purple / 4 = orange / 5 = gold
-- drop true/false = if allready learned recipes should be dropped
-- logg true/false enables log function
you call it like this:

Code: Select all

CleanBag(1000, 2, true, false)
1000 is how much it should sell for to be kept, 3 is as shown above, rarity color, true is for dropping recipies you allready have.

rest should be selfexplainatory.

oh, it also logs items it throws away, learns and use, in the logfolder ^^

Botje
Attachments
userfunction_CleanBag.lua
2.5
(4.78 KiB) Downloaded 539 times
Last edited by botje on Sun Jan 06, 2013 11:49 am, edited 14 times in total.

User avatar
botje
Posts: 656
Joined: Wed Oct 27, 2010 7:17 am

Re: Cleanbag userfunction

#2 Post by botje » Thu Aug 18, 2011 12:17 pm

anybody with suggestions please let me know, im not that good at lua ya know :P

Botje

edit: seems only first bag gets checked, anyone a idea?

code should work as far as i know >.<

edit2: nvm, found it xd

Tamyra
Posts: 133
Joined: Tue Feb 01, 2011 6:09 pm

Re: Cleanbag userfunction

#3 Post by Tamyra » Thu Aug 18, 2011 1:57 pm

I know off topic, but could not find somewhere to ask:

Okay not sure if it is my work firewall blocking it suddenly, but I'm asking just in case. Is the wiki down?

User avatar
botje
Posts: 656
Joined: Wed Oct 27, 2010 7:17 am

Re: Cleanbag userfunction

#4 Post by botje » Thu Aug 18, 2011 5:15 pm

sigh... now second bag gets checked, but first isnt... xd

any help please? :P


oooooooooh, now i get it, the bot and game use different slots, it has a offset of 60 :)

Botje

User avatar
lisa
Posts: 8332
Joined: Tue Nov 09, 2010 11:46 pm
Location: Australia

Re: Cleanbag userfunction

#5 Post by lisa » Thu Aug 18, 2011 7:17 pm

I would probably add in a

Code: Select all

inventory:update();
like this

Code: Select all

function CleanBag(sellprize, rarity)
inventory:update();
for i, item in pairs(inventory.BagSlot) do
Something to also keep in mind is arrows are in the Weapons type, so if a scout has arrows within the slot ranges they will get deleted and a scout without arrows = dead, just means people have to be very careful what they have within the from and to slot ranges in profile. I mention arrows because if they get bought from vendor they just go to first available slot, so if you clean bags later on you could delete the arrows you bought.
Could probably do a check for the RELOAD_AMMUNITION = arrows in profile and if so then to check for highest lvl of arrow in bag and ignore it.
Remember no matter you do in life to always have a little fun while you are at it ;)

wiki here http://www.solarstrike.net/wiki/index.php?title=Manual

User avatar
rock5
Posts: 12173
Joined: Tue Jan 05, 2010 3:30 am
Location: Australia

Re: Cleanbag userfunction

#6 Post by rock5 » Thu Aug 18, 2011 10:42 pm

How about a default value for rarity?

Code: Select all

if rarity == nil then rarity = 2 end
  • Please consider making a small donation to me to support my continued contributions to the bot and this forum. Thank you. Donate
  • I check all posts before reading PMs. So if you want a fast reply, don't PM me but post a topic instead. PM me for private or personal topics only.
  • How to: copy and paste in micromacro
    ________________________
    Quote:
    • “They say hard work never hurt anybody, but I figure, why take the chance.”
          • Ronald Reagan

User avatar
botje
Posts: 656
Joined: Wed Oct 27, 2010 7:17 am

Re: Cleanbag userfunction

#7 Post by botje » Fri Aug 19, 2011 8:54 am

thanx guys, ill add those suggestions ^^

Botje

kanta
Posts: 424
Joined: Thu Nov 11, 2010 4:08 pm

Re: Cleanbag userfunction

#8 Post by kanta » Sun Aug 21, 2011 8:55 pm

Just to be sure I'm understanding correctly, the rarity value drops all colors up to the value you enter? Such as using 2 will drop white, green and blue under a certain gold value?
Scout/Knight/Rogue 70/66/66

User avatar
botje
Posts: 656
Joined: Wed Oct 27, 2010 7:17 am

Re: Cleanbag userfunction

#9 Post by botje » Mon Aug 22, 2011 2:10 am

no, everything beneath it, you tell what to keep sort of speak :)

Botje

kanta
Posts: 424
Joined: Thu Nov 11, 2010 4:08 pm

Re: Cleanbag userfunction

#10 Post by kanta » Tue Aug 23, 2011 2:13 pm

Ah ok, thank you very much. This is a much better option than adding every item to the Lootomatic drop filter :)
Scout/Knight/Rogue 70/66/66

User avatar
botje
Posts: 656
Joined: Wed Oct 27, 2010 7:17 am

Re: Cleanbag userfunction

#11 Post by botje » Tue Aug 23, 2011 5:20 pm

your very welcome, and yes, thats why i made/copied this.

i got sick of adding stuff in lootfilter, i even think i maxed it, it wont let me add anymore items xd

Botje

Shogun
Posts: 45
Joined: Wed Jul 27, 2011 6:08 am

Re: Cleanbag userfunction

#12 Post by Shogun » Wed Aug 24, 2011 9:56 am

Nice, I will switch to that.

Here is what I use to determine the rarity for a modified BagCleanerSeller:

Code: Select all

			local table_quality = {"white","green","blue","purple","orange","gold"};
			local nMaxQuality;
			for i,v in pairs(table_quality) do
				if nil ~= string.find(settings.profile.options.INV_AUTOSELL_QUALITY, v) then
					nMaxQuality = i - 1;
				end
			end

User avatar
Nero
Posts: 98
Joined: Wed Aug 10, 2011 9:07 am

Re: Cleanbag userfunction

#13 Post by Nero » Wed Oct 05, 2011 11:35 am

Say, how does this function deletes those items? It looks like it's via

Code: Select all

item:delete()
when certain requirements are met. Problem is - I didn't found any such function on wiki, and putting it into search option didn't really give me anything useful.

How should I go about it when I would want to delete item with particular ID? Or it's just enough to paste something like item:delete(ID)?

And when it is, would changing this line

Code: Select all

if (item:isType("Weapons") or item:isType("Armor")) and sellprize > item.Worth and item.Quality < rarity then
to something that would check for a list of ID's specified by me, and those items would get deleted as well? (well, I don't really know how to do this - but this, I should manage to find. And yes, I know that I would need to mess around with other settings along with it, but that shouldn't be too hard)


Just noticed - isType is, yet again, neither to be found on wiki, nor explained on forums. How the heck do you guys know what are it's uses? Am I missing some large trove of info?

Cheers


Edit - I've searched around in various things in bot files, and found item:delete() in item.lua. There are two lines
RoMScript("PickupBagItem("..self.BagId..");");
RoMScript("DeleteCursorItem();");

So.. it deletes specified item.. although how is it specified? self.BagId means ID?
Last edited by Nero on Wed Oct 05, 2011 11:57 am, edited 2 times in total.

User avatar
botje
Posts: 656
Joined: Wed Oct 27, 2010 7:17 am

Re: Cleanbag userfunction

#14 Post by botje » Wed Oct 05, 2011 11:50 am

oh thats easy, the big trove of info is called Rock5 and Lisa :)

They helped a LOT with this, because im not that good at Lua :P

EDIT:
btw, i think you can take that part out of the lootfilter addon, that uses a list too :)

Botje

User avatar
Nero
Posts: 98
Joined: Wed Aug 10, 2011 9:07 am

Re: Cleanbag userfunction

#15 Post by Nero » Wed Oct 05, 2011 11:56 am

Thanks for the quick reply.

So, to make it short - using Item:delete(50000) will delete item with ID 50,000 as long as I have it in my bag?

Thanks for the idea of checking out lootfilter - would probably help me in it

User avatar
botje
Posts: 656
Joined: Wed Oct 27, 2010 7:17 am

Re: Cleanbag userfunction

#16 Post by botje » Wed Oct 05, 2011 12:03 pm

as far as i know that should work, but yeah.

lootfilter is your pall in this case, good luck ^^

botje

User avatar
rock5
Posts: 12173
Joined: Tue Jan 05, 2010 3:30 am
Location: Australia

Re: Cleanbag userfunction

#17 Post by rock5 » Wed Oct 05, 2011 9:15 pm

You have to understand about classes. You can think of a class as a pattern or template. The CItem object never gets created as CItem. It's used to create the items. Items created in the inventory are based on CItem and have thier own version of all the attributes and function CItem has.

So for example:

Code: Select all

feed = inventory:findItem("Feed Bag")
Will create an item "feed" that has all the attributes and functions you find in item.lua. So "feed" will be a particular item. The function associated with "feed" are for acting upon that item. So

Code: Select all

feed:delete()
will delete that item.

Other items or objects based on classes are:
  • inventory - based on CInventory
    player - based on CPlayer and CPawn
    When mobs objects are created - based on CPawn
    __WPL - based on CWaypointList
    The actual points in the waypointlist - based on CWaypoint
I hope that helps.
  • Please consider making a small donation to me to support my continued contributions to the bot and this forum. Thank you. Donate
  • I check all posts before reading PMs. So if you want a fast reply, don't PM me but post a topic instead. PM me for private or personal topics only.
  • How to: copy and paste in micromacro
    ________________________
    Quote:
    • “They say hard work never hurt anybody, but I figure, why take the chance.”
          • Ronald Reagan

xrozhija
Posts: 51
Joined: Sat Apr 25, 2009 2:08 am

Re: Cleanbag userfunction

#18 Post by xrozhija » Thu Sep 13, 2012 10:44 am

How would i go about making this userfunction also delete runes, amulet of light, ammo and potions up to a cetain level?

The potion part, I would like it to only delete potions lower than level 46, as those are the ones i use. (Elemental Spirit Stone, if name has anything to say)

Jandrana
Posts: 187
Joined: Thu Jul 05, 2012 5:53 am

Re: Cleanbag userfunction

#19 Post by Jandrana » Fri Sep 14, 2012 4:23 am

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.

User avatar
botje
Posts: 656
Joined: Wed Oct 27, 2010 7:17 am

Re: Cleanbag userfunction 2.0

#20 Post by botje » Tue Nov 27, 2012 10:33 am

updated to version 2.0

recipies and cards are getting used now, if you dont have them.

Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests