Find Row that contains 3 values within its columns
3absh
Member Posts: 601
What should I write (using the table search function) If I needed to search part of the table
Say
-columns 1 to 3
-Rows 1 to 5
For 3 values not 1
For example I want to find the Row that contains the values "d", "c", "a" within its columns (not necessarily in that order-in this case the result should be Row 14)
Comments
The point of this is 3 ingredients when combined displays the 4th column which is the cooked food
In order to make things easier, I combined the three letter in a new column
This is what I wrote after adding the new column which combines all letters
The issue here is that the column being searched (for example d,c,a referred here by an image name of another actor) letters have to be in that order or else the row won't be identified
Is it always three ingredients per recipe? And the player can freely choose any ingredients?
Contact me for custom work - Expert GS developer with 15 years of GS experience - Skype: armelline.support
I would use tableMergeValues() to create a text string for each row and place that in a loop to get through the required rows. Then use Text Expression as a rule condition to check for "contains" for each letter. So three rules for the three possible values. Ugh, kind of a mess but it could work.
Edit: I hope I don't get the Dog Food.
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
Here's a demo.
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
It didn't work
I tried a different order of the combined letters and it displayed Nothing Found..
I think the only solution here to continue the Permutation of the letters and refer the repeated values (in a new column) to the row already containing them
For example
ABC Row 1
ABD Row2
.
.
.
CBA Row 1
and So on
It's the long way to solve I didn't want to go this route but I guess I have to
I did this and it seems to work
Thanks @tatiang for reminding me of "Loop Over Table"
tableCellValue( game.RecipesTBL , self.rowIndex ,11) Contains Scene.Background.Ingredient1.Image
and so on
The 11th column mentioned here is simply a column that contains the first 3 columns merged
1 2 3 ... 11
A B C ABC
Sorry, I somehow ignored the aspect of needing the letters in any order!
Glad it at least provided some inspiration for moving forward.
So to adjust mine, you'd have to have six separate rules, one for each possible combination of three letters. Yuck.
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
This could be better done with a numerical algorithm. This would leave you looking for number specific totals that relate to the item. This would slim down the amount of rules et... more work to figure out the algorithm but way less code work.
Guru Video Channel | Lost Oasis Games | FRYING BACON STUDIOS