Proposed change to item types

Runes of Magic/Radiant Arcana (http://www.runesofmagic.com)
Post Reply
Message
Author
User avatar
rock5
Posts: 12173
Joined: Tue Jan 05, 2010 3:30 am
Location: Australia

Proposed change to item types

#1 Post by rock5 » Wed May 16, 2012 9:47 am

A while back I implemented the 3 levels of item types which are saved to "rom/cache/itemtypestable.lua" and the isType function. With it you could write things like

Code: Select all

if item:isType("Armor") or item :isType("Weapons") then -- All gear
or

Code: Select all

if item:isType("Weapons") and not (item:isType("Projectiles") or item:isType("Arrows")) then -- All weapons but not projectiles and arrows.
It also allows you to specify any types in the autosell options.

Anyway, at the time, seeing as similar armors had similar type name (eg. the 3rd level type name for plate belt is "Belts" and so is the chain, leather and cloth ones) I thought I was being helpful by merging the second and third level type names, eg. instead of the level 2 name being "Plate" and the level 3 name being "Belts", I saved it as level 2 "Plate" and level 3 as "Belts Plate". That way all type names are uniquie and you could use item:isType("Belts Plate") to indicate one type of item.

I long since realised this was a mistake as there is no way to say "is it any type belt". What I should have done is left it as "Belts" and if you wanted to know if an item is a plate belt you could have just used

Code: Select all

if item:isType("Plate") and item:isType("Belts") then
This is now causing me problems with a function I'm writing for auto equiping gear after getting quest rewards.

The question I'm putting forward is, will people get annoyed if I change this? It will mostly affect people who have used "type" options in their autosell options. It will only affect armor.

I suspect it wont affect anyone as I don't think anyone would be using the 3rd level type names. Probably only the more advanced programmers who could probably easily change it.

I just had a thought. If they don't all have unique names then you can't specify an item such as plate belts in the autosell options. They have to be unique.

I think what I can do is give the third level types both name "Belts" and "Belts Plate" so all existing code and user options will still work and both

Code: Select all

if item:isType("Belts Plate") then
and

Code: Select all

if item:isType("Belts") and item:isType("Plate") then
will work.

Ok, I have a plan of action. Thanks for listening. Seems pointless to post this now but I think some people like to see how I think. :D
  • 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

BillDoorNZ
Posts: 446
Joined: Wed Aug 03, 2011 7:37 pm

Re: Proposed change to item types

#2 Post by BillDoorNZ » Wed May 16, 2012 9:29 pm

meh, change it!!!! do it!!!

we'll survive :)

IronWolf
Posts: 50
Joined: Sun Aug 08, 2010 7:09 am

Re: Proposed change to item types

#3 Post by IronWolf » Thu May 17, 2012 12:26 am

NoooOOOoooOoooOooooo.... oh wait.. eh.. yah... never used that, never mind, you go girl!! :)

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

Re: Proposed change to item types

#4 Post by rock5 » Thu May 17, 2012 3:14 am

IronWolf wrote:NoooOOOoooOoooOooooo.... oh wait.. eh.. yah... never used that, never mind, you go girl!! :)
:) Yeah, seeing as my final idea doesn't affect any existing code, I went ahead and did it already.

Now items with non-unique subsubtypes have 2 names eg.

Code: Select all

[2] = { Name = "Belts", UniqueName = "Belts Plate" },
And various functions have been ammended to check for both. Works fine.
  • 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

sirkitesalot
Posts: 4
Joined: Fri Jul 13, 2012 8:21 pm

Re: Proposed change to item types

#5 Post by sirkitesalot » Sat Jul 14, 2012 7:36 pm

Sorry May not be in the right place but I believe it is a semi related question.

How do you tag a specific items
in the below sample the function will drop any runes picked up
Code:

if item:isType("Runes") then
item:delete()
end

I am looking to know how to drop specific items such as a rune "Magic III"

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

Re: Proposed change to item types

#6 Post by lisa » Sat Jul 14, 2012 8:54 pm

when you use the "item" it has values which are these.

Code: Select all

		self.BaseItemAddress = nil;
		self.Empty = true;
		self.Id = 0;
		self.Name = "<EMPTY>";
		self.ItemCount = 0;
		self.Color = "ffffff";
		self.Icon = "";
		self.ItemLink = "|Hitem:33BF1|h|cff0000ff[Empty]|r|h";
		self.Durability = 0;
		self.MaxDurability = 0;
		self.Quality = 0; -- 0 = white / 1 = green / 2 = blue / 3 = purple / 4 = orange / 5 = gold
		self.Value = 0;
		self.Worth = 0;
		self.InUse = false;
		self.BoundStatus = 1; -- 0 = bound on pickup, 1 = not bound, 2 = binds on equip and bound, 3 = binds on equip and not bound
		self.Bound = true
		self.RequiredLvl = 0;
		self.CoolDownTime = 0;
		self.LastTimeUsed = 0;
		self.MaxStack = 0;
		self.ObjType = 0;
		self.ObjSubType = 0;
		self.ObjSubSubType = 0;
		self.Stats = {}; -- list of named stats and their ids.
		self.ItemShopItem = false
		self.CanBeSold = false
		self.LastMovedTime = 0
So you can use any of those to do what you want, in your case item.Name would be enough. Note just imagine all those "self" are "item"

ie

Code: Select all

if item.Name == "Magic III" then item:delete() end
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

sirkitesalot
Posts: 4
Joined: Fri Jul 13, 2012 8:21 pm

Re: Proposed change to item types

#7 Post by sirkitesalot » Sat Jul 14, 2012 11:33 pm

Perfect Thanks Lisa.

BillDoorNZ
Posts: 446
Joined: Wed Aug 03, 2011 7:37 pm

Re: Proposed change to item types

#8 Post by BillDoorNZ » Sun Jul 15, 2012 4:15 pm

I found that I was forever going through my bags throwing out useless runes etc so I shamelessly stole the code from the CleanBag userfunction as I'm too lazy to manually maintain my bags :)

Basically, I changed it to use the INV_AUTOSELL_FROMSLOT and INV_AUTOSELL_TOSLOT ranges so I can make sure it doesn't sell stuff I want to keep. I then extended it to take a table of things to sell (it ignores value tho :):

e.g. I call it like this:

Code: Select all

CleanBagMatch({ ". I$", ". II$", "Vanquisher's Loot", "Link Rune", "Southern Fern", "Legends of Tab.*", "Throwing *"});
This will drop all items that:
end in 'I' or 'II'
are Vanquishers Loot
are Link Runes
are Southern Fern
are Legends of Tab*
are Throwing *

The function is shown below (I added it into the userfunction_CleanBag.lua file).

Code: Select all

function CleanBagMatch(_names)
	if (_names == nil) then
		printf("CleanBagMatch requires the names parameter to be set\n");
		return;
	end;
	
	inventory:update();
	
	for k,v in pairs(_names) do
		_names[k]=string.lower(v);
	end;

	for i, item in pairs(inventory.BagSlot) do
		if item.SlotNumber >= settings.profile.options.INV_AUTOSELL_FROMSLOT + 60 and
		settings.profile.options.INV_AUTOSELL_TOSLOT + 60 >= item.SlotNumber then

			local match = false;
			local itemName = string.lower(item.Name);
			--printf(""..tostring(itemName).."\n");
			for l,j in pairs(_names) do
				--printf("\t\tcomparing to: "..tostring(j).."\n");
				if (string.find(itemName, j)) then match = true; break; end;
			end;
			
			--printf("\t\t"..tostring(match).."\n");

			if (match == true) then
				printf("Deleting Item:  "..item.Name.." [$"..tostring(item.Worth).." : "..tostring(item.Quality).."]\n");
				item:delete()
				local filename = getExecutionPath() .. "/logs/CleanBag.log";
				local file, err = io.open(filename, "a+");
				if file then
					file:write(" Deleted: " ..item.Name.. ". [$"..tostring(item.Worth).." : "..tostring(item.Quality).."] \tDate: " .. os.date() .. ".\n")
					file:close();
				end
			end
		end
	end
end
As always, use at your own risk - it's never caused me any problems (been running it regularly for months now), but if anything goes wrong, it wasnt me :)

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

Re: Proposed change to item types

#9 Post by rock5 » Mon Jul 16, 2012 1:20 am

Your code will surely be of help but I get the impression you don't fully follow pattern matching as I see errors here (even although they may have actually worked).
BillDoorNZ wrote:

Code: Select all

CleanBagMatch({ ". I$", ". II$", "Vanquisher's Loot", "Link Rune", "Southern Fern", "Legends of Tab.*", "Throwing *"});
For the sake avoiding confusing users of your function, I'll explain some of the sybols they might use.

Firstly, if you don't use any pattern matching symbols then it will match the whole string. So if you used "Rune" it will match any item with the word "Rune" anywhere in it's name.

$ - If you want to match the end of a word, eg. rune names that end in " I", but not names that have " I" in the middle of them, eg. "Ancient Iguanna Tail", then you can use $ to indicate it should only match at the end of a word. So you would use " I$". So that will match only names that end in " I".

^ - BillDoorNZ didn't use it but just to be thorough, the opposite of $ is ^. So if you want to match only the begining of a name you could use something like "^Rune", so only names that start with Rune.

. - This means "match any character", eg. "Level . Potion" will match "Level 1 Potion", "Level 2 Potion" etc. but won't match "Level 11 Potion".

* - This means "match any multiple of the previous letter or pattern". So "Level .* Potion" will match "Level 1 Potion", "Level 22 Potion" and even "Level 2 Supercalfragalisticexpialatotious Concentrated Potion".

For more complex patterns visit
http://www.lua.org/manual/5.1/manual.html#5.4.1
But be warned, pattern matching can get hugely complex and confusing.
  • 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

BillDoorNZ
Posts: 446
Joined: Wed Aug 03, 2011 7:37 pm

Re: Proposed change to item types

#10 Post by BillDoorNZ » Mon Jul 16, 2012 5:51 pm

heh...sorry about that Rock,

should have added a link for the Regex stuff meself :)

And I second the complexity bit!!! Can be incredibly confusing.

Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 4 guests