Page 1 of 1

How to detect a recipe is learned or not? --solved--

Posted: Tue Nov 13, 2012 10:36 am
by botje
i want to write a little function that scans my bags, and when it encounters a recipe, it checks if its allready learned, if it is, i add it to lootfilter with a slash script, else i add it to lootfilter and use it.

this will learn them automaticly and keep my bags clean :3

but i am stuck on the part of detecting the learned state...

Botje

edit, instead of relying on lootfilter, i can also thrash them ofcourse...

thanx rock, here is my final version :)

Code: Select all

function LearnRecipe(drop) -- true or false
	inventory:update();
	
	if drop == nil then drop = false
	
	for i, item in pairs(inventory.BagSlot) do
		if 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
			
		end
	end
end

Re: How to detect a recipe is learned or not?

Posted: Tue Nov 13, 2012 10:53 am
by rock5
It's complicated because you need to use more than 1 function. I made a userfunction for crafting stuff called "userfunction_craftitem.lua". It has a function in it that returns a match if you have the ingredients to make something. I could modify it to do what you ask.

Re: How to detect a recipe is learned or not?

Posted: Tue Nov 13, 2012 11:08 am
by rock5
Actually, it turned out to not be that difficult, given that you need to find a recipe in your inventory first and you can use it's id.

Try this, lets say "item" is the recipe, however you searched for it. Then

Code: Select all

if RoMScript("GetCraftItemInfo("..item.Id..")") == nil then -- Don't have it
    item:use() yrest(3000)
end

Re: How to detect a recipe is learned or not? --solved--

Posted: Tue Nov 13, 2012 5:36 pm
by botje
thanx for the help rock, added full function to first post :)

Re: How to detect a recipe is learned or not? --solved--

Posted: Tue Nov 13, 2012 5:51 pm
by Cindy
Any way to add a configuration item for color of recipe? (for example, to be able to exclude purple recipes from deletion)?

Re: How to detect a recipe is learned or not? --solved--

Posted: Tue Nov 13, 2012 6:37 pm
by lisa
item.Color

just add in a check for the color you don't want to delete and obviously don't delete it.

Re: How to detect a recipe is learned or not? --solved--

Posted: Tue Nov 13, 2012 6:53 pm
by botje
hmm, didnt think of that xd

ill add that :3

Re: How to detect a recipe is learned or not? --solved--

Posted: Mon Nov 19, 2012 8:41 am
by botje
hmm... dont recipe's have like the same rarity as other items?

so i can use

Code: Select all

and item.Quality < rarity then
this?