Searching for items in invetory

Pazleysox

Member
Is it possible to string together a search for multiple items?

Code:
	if($item[1, 2, 3, 4].available_amount() > 0  )

or does it have to be each item individually?
Code:
	if($item[1].available_amount() > 0 || $item[2].available_amount() > 0 || $item[3].available_amount() > 0 ||)
 

Bale

Minion
If you do that more than once, make a function for it.

Code:
boolean any_item_available(boolean [item] list) {
   foreach it in list
      if(available_amount(it) > 0)
         return true;
   return false;
}

if(any_item_available($items[1, 2, 3, 4]))
   print("One of those is in inventory.");
 

Pazleysox

Member
Code:
// check 1
		{
		boolean any_item_available(boolean [item] list) {
		   foreach it in list
		      if(available_amount(it) >= 2)
		         return true;
		   return false;
		}

		if(any_item_available($items[1, 2, 3]))
		{
		   print("You can use lvl 1");
		itemcheck1();
		}
		else {
			print("You don't have enough for lvl 1, advancing to check level 2");
		} }

//check 2
		{
		boolean any_item_available(boolean [item] list) {
		   foreach it in list
		      if(available_amount(it) >= 1)
		         return true;
		   return false;
		}

		if(any_item_available($items[4, 5, 6]))
		 {
		print ("You have first item for level check 2");
		itemcheck2(); 
		}
		else {
		print("You can not use it");
		} }
Here's a sample of the code I'm working on. The problem I'm having is getting the script to stop looking at check2 if check1 passes. I tried doing this:
Code:
		if(any_item_available($items[1, 2, 3]))
		{
		   print("You can use lvl 1");
		itemcheck1();
                break;
		}
		else {
			print("You don't have enough for lvl 1");
But I get this error "Encountered 'break' outside of loop (Script.ash line XX)"

How can I get around this? I'm sure it's simple, I just don't know enough about this to figure it out. lol
 
Last edited:

AlbinoRhino

Active member
Here's a sample of the code I'm working on. The problem I'm having is getting the script to stop looking at check2 if check1 passes. I tried doing this:
How can I get around this? I'm sure it's simple, I just don't know enough about this to figure it out. lol


I think you are trying for something like this, though I'm not sure. Note that I have added an "int amt" argument to the any_item_available function, rather than duplicating that code for different item amounts. Hope this helps.


PHP:
#this will return true if you have the requested amount of any 1 of the 3, which I'm not sure if that's what you are wanting
boolean any_item_available(boolean [item] list, int amt) {
           foreach it in list
              if(available_amount(it) >= amt)
                 return true;
           return false;
}


if(any_item_available($items[1, 2, 3], 2))
{
           print("You can use lvl 1");
}
else if ( any_item_available($items[4, 5, 6], 1) )
{
           print("You don't have enough for lvl 1");
           print ("You have first item for level check 2");
}
else
{
           print ("You can not use it");
}
 

Pazleysox

Member
Ok, I've been trying to work on this script for days, and I'm just not script savvy enough to figure it out. I'm not even sure if what I want it to do is possible. I've been trying for days, and dozens, and dozens of combinations, and looked at tons of other scripts to figure it out, and for the life of me, I can not.

Thank you Bale, and AlbinoRhino, for all your help thus far!

Code:
// item +150% check, must = 1
		{
		boolean any_item_available(boolean [item] list, int amt) {
		   foreach it in list
		      if(available_amount(it) >= amt)
		         return true;
		   return false;
		}


		if(any_item_available($items[5421, 4851, 921, 3091, 5381, 4331, 5401, 5321, 4151, 5481, 3631, 4181, 4191, 8151, 6831, 6841], 1) && (any_item_available($items[5420, 5400, 4330, 5320, 3290, 3760, 5480, 2220, 4180, 6840, 8150, 7710], 1)))
		{
			print("You can cast Sweet Synthesis Collection: 150% Item Drop","green");
		}
		else if (any_item_available($items[3269, 5419, 5319, 5459, 4329, 5189, 5479, 4389, 1999, 4179, 7499, 8149, 7919, 6399], 1) && (any_item_available($items[1382, 5422, 4332, 5402, 5382, 5482, 4462, 3422, 4182, 6852, 6172, 9252], 1)))
		{
			print("You can cast Sweet Synthesis Collection: 150% Item Drop","green");
		}
		else if (any_item_available($items[5458, 5418, 4818, 5318, 5398, 4758, 4518, 3428, 4178, 7918], 1) && (any_item_available($items[4333, 5423, 5383, 2193, 5413, 5483, 2943, 4163, 4463, 4623, 4393, 5023, 3423, 5473, 4853, 5103, 4273, 4183, 6833, 6903, 6843, 5913], 1)))
		{
			print("You can cast Sweet Synthesis Collection: 150% Item Drop","green");
		}
		else if (any_item_available($items[2197, 5417, 5397, 5317, 4467, 5157, 5457, 8257, 6837, 7917, 8537], 1) && (any_item_available($items[5494, 4334, 5424, 5384, 3584, 5484, 3054, 4464, 4394, 3424, 5474, 4164, 5414, 4744, 6834, 7914, 3124, 8154, 6404, 6904, 7474], 1)))
		{
			print("You can cast Sweet Synthesis Collection: 150% Item Drop","green");
		}
		else if (any_item_available($items[5496, 5416, 5406, 5396, 4256, 4466, 3046, 4746, 3426, 4176, 5526, 6836, 5736, 9146], 1) && (any_item_available($items[5495, 5425, 2955, 5405, 5385, 5395, 4465, 4395, 3425, 5475, 5415, 5345, 1345, 3125, 4745, 6835, 7915, 6405], 1)))
		{
			print("You can cast Sweet Synthesis Collection: 150% Item Drop","green");
		}
		else if (any_item_available($items[5496, 5416, 5406, 5396, 4256, 4466, 3046, 4746, 3426, 4176, 5526, 6836, 5736, 9146], 1) && (any_item_available($items[5420, 5400, 4330, 5320, 3290, 3760, 5480, 2220, 4180, 6840, 8150, 7710], 1)))
		{
			print("You can cast Sweet Synthesis Collection: 150% Item Drop","green");
		}
		else {
			print("You can not cast Sweet Synthesis Collection: 150% Item Drop", "red");
		}}

This is a snippet of what I've written. It works exactly as I would have hoped, just to be a quick informative script that shows what candy syntheses I can use, and what I cant. I know that Mafia does this too It took me a while to figure that out though.

Down to what I'm actually looking for.
I want the ability to see what I can still cast, but if I'm in ronin, or HC, I know there is limited access to candy (no mall access, etc)
I would like the script to be able to say "You can use this candy for this buff, and this buff, but only have enough to do one, not both" Sorta like, if you do this, you won't be able to do THAT, but you can do THAT right now.

It will help make decisions as to which candy to use for which buff.


If this is possible, and requires a lot of doing the same coding for each buff, I'm willing to put in the work for that, but really need help getting it started.

I'm willing to pay for the help. I re-read the first post in this forum section, and it said offer a Mr. A for payment. Well, I'm offering a Mr. A! If what I'm asking is worth more, I'm willing to pay more!

I could probably write the script to check each combination of candy, but I know there's an easier, and more efficient way to do it.

Paz
 
Last edited:

Bale

Minion
Just for the record, since he quoted my name. I never recommended making hard coded lists of candy. It would be better to make a list of complex and simple candies and then perform mod 5 calculations on them. If you really want lists of candies. For some reason he really wants the lists of candies although I have tried to talk him out of them.

That would be my second choice. Mafia already calculates this for us.

Code:
if(count(sweet_synthesis_pair( $effect[Synthesis: Collection] )) > 0)
   print("You can cast Sweet Synthesis Collection: 150% Item Drop","green");

That approach only fails when you're trying to figure out more than just a single effect that can be gained. If you want to know what you can cast after using candies for that effect then it gets more complicated. For that I'd make an array of all candies and iterate sweet_synthesis_pairing( effect, item ) on them.
 
Last edited:
Top