any code to detect if a card is owned?

Runes of Magic/Radiant Arcana (http://www.runesofmagic.com)
Post Reply
Message
Author
User avatar
botje
Posts: 656
Joined: Wed Oct 27, 2010 7:17 am

any code to detect if a card is owned?

#1 Post by botje » Mon Nov 26, 2012 1:27 pm

as title, any snippets that help me detect if a monster card is owned or not?

thanx in advance

User avatar
grande
Posts: 261
Joined: Tue Jun 28, 2011 4:46 pm

Re: any code to detect if a card is owned?

#2 Post by grande » Mon Nov 26, 2012 5:53 pm

Hey howdy botje. There is an addon that will paint "learned" or unlearned in green/red on the card. Maybe something from the addon could be modded to meet your needs in a script but I'm not sure. Sorry couldn't help more.

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

Re: any code to detect if a card is owned?

#3 Post by rock5 » Mon Nov 26, 2012 11:14 pm

Ok made a little function. tag: havecard

Code: Select all

function haveCard(idorname)
	if type(idorname) == "string" and type(tonumber(idorname)) ~= "number" then
		idorname = "\""..idorname.."\""
	end
	return RoMScript("} for x=0,15 do "..
		"local cc=LuaFunc_GetCardMaxCount(x) "..
		"if cc~=nil and cc>0 then "..
			"for y=1,cc do "..
				"local i,f,n=LuaFunc_GetCardInfo(x,y-1) "..
				"if i=="..idorname.." or n=="..idorname.." then "..
					"a={f==1} "..
				"end "..
			"end "..
		"end "..
	"end z={")
end
It accepts names or ids. Note: it only accepts the creature name, not the full card name. So this wont work.

Code: Select all

haveCard("Card - Abyssal Shadow")
But these will

Code: Select all

haveCard("Abyssal Shadow")
haveCard(771059)
haveCard("771059")
Of course you will still need to look for cards in your inventory. Let me know if you need help with that too.
  • 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: any code to detect if a card is owned?

#4 Post by botje » Tue Nov 27, 2012 3:04 am

nice rock :)

Code: Select all

function CleanBag(sellprize, rarity, drop)
	inventory:update();
	
	if sellprize == nil then sellprize = 750 end;
	if rarity == nil then rarity = 1 end;
	if drop == nil then drop = false 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
			if (item:isType("Weapons") or item:isType("Armor")) and sellprize > item.Worth and item.Quality < rarity then
				printf("Deleting Item:  "..item.Name.."\n");
				item:delete()
				
				logInfo("CleanBag", "Deleted: " ..item.Name.. "." , true)
			elseif item:isType("Recipes") then
				if RoMScript("GetCraftItemInfo("..item.Id..")") == nil then -- Don't have it
					printf("Learning recipe:  "..item.Name.."\n");
					logInfo("LearnRecipe", "Learning recipe:  " ..item.Name.. "." , true)
					item:use();
					yrest(5000);
				else
					if drop == true then
						printf("Deleting Recipe:  "..item.Name.."\n");
						item:delete()
					end
				end
			elseif item:isType("Monster Cards") then
			
			end
		end
	end
end
i would like to put that in my cleanbag function, but would i use item:id to pass it on to the function you made?

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

Re: any code to detect if a card is owned?

#5 Post by rock5 » Tue Nov 27, 2012 3:52 am

Yes,

Code: Select all

haveCard(item.Id)
  • 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: any code to detect if a card is owned?

#6 Post by botje » Tue Nov 27, 2012 4:21 am

and what exactly does it return? i cant seem to get that from your function, true/false, or 1/2 or???

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

Re: any code to detect if a card is owned?

#7 Post by rock5 » Tue Nov 27, 2012 4:52 am

Sorry, true or false (or nil I guess if it doesn't make a match). So you would use it like this for example

Code: Select all

if haveCard(item.Id) then
    item:delete()
else
    item:use() yrest(3000)
end
If you're curious, it gets the true or false from "a={f==1}". When a RoMScript is written like that ie "} some code; a={somevalues} z={" then it returns the values in 'a'. 'f' is the flag of whether you have the card or not. If you do have the card then 'f' should be 1. f==1 is either true or false so the "a={f==1}" will return true or false. I hope that made some sense.
  • 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
lisa
Posts: 8332
Joined: Tue Nov 09, 2010 11:46 pm
Location: Australia

Re: any code to detect if a card is owned?

#8 Post by lisa » Tue Nov 27, 2012 5:43 am

I am just amazed you got it all into a single macro =)
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: any code to detect if a card is owned?

#9 Post by rock5 » Tue Nov 27, 2012 6:14 am

It was easy, still plenty of room. I still remember what I went through creating the code that gets all the item types from the game. The initial code took about 15 seconds I think or maybe longer, I don't remember exactly. Doing a RoMScript for each type probably meant it was doing well over 120 RoMScripts. Now I think it does it in about 15. Takes about 2.5s :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

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

Re: any code to detect if a card is owned?

#10 Post by botje » Tue Nov 27, 2012 6:25 am

now all i need is a way to use the recipe color to keep everything from that color upwards and my cleanbag is done :)

thanx rock ^^

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

Re: any code to detect if a card is owned?

#11 Post by rock5 » Tue Nov 27, 2012 6:31 am

That should be easy. 'item' has a Quality value after all.
  • 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: any code to detect if a card is owned?

#12 Post by botje » Tue Nov 27, 2012 6:32 am

i could not find that on the recipe one O.o

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

Re: any code to detect if a card is owned?

#13 Post by rock5 » Tue Nov 27, 2012 6:42 am

All inventory items have Quality even recipes.

Code: Select all

Command> print(inventory.BagSlot[61].Name)
Recipe - Tador's Brilliant Armor
Command> print(inventory.BagSlot[61].Quality)
3
  • 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: any code to detect if a card is owned?

#14 Post by botje » Tue Nov 27, 2012 6:46 am

cool, then its indeed easy, thanx ^^

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest