Find Row that contains 3 values within its columns

3absh3absh Member, PRO Posts: 582
edited May 2017 in Working with GS (Mac)

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

  • 3absh3absh Member, PRO Posts: 582

    The point of this is 3 ingredients when combined displays the 4th column which is the cooked food

  • 3absh3absh Member, PRO Posts: 582

    In order to make things easier, I combined the three letter in a new column

  • 3absh3absh Member, PRO Posts: 582
    edited May 2017

    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

  • ArmellineArmelline Member, PRO Posts: 4,920

    Is it always three ingredients per recipe? And the player can freely choose any ingredients?

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,926
    edited May 2017

    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. :s

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,926

    Here's a demo.

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • 3absh3absh Member, PRO Posts: 582

    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

  • 3absh3absh Member, PRO Posts: 582

    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

  • 3absh3absh Member, PRO Posts: 582
    edited May 2017

    The 11th column mentioned here is simply a column that contains the first 3 columns merged

    1 2 3 ... 11
    A B C ABC

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,926
    edited May 2017

    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

  • The_Gamesalad_GuruThe_Gamesalad_Guru Member Posts: 9,914

    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.

Sign In or Register to comment.