How to Call Multiple Values from a Table Row?

Hello! Is there a way to create a rule that will check the value in a table cell, and if the cell value is not equal to zero, move on to the next column over until it reaches a cell that does contain a zero, then stop?

Comments

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    Sure. You can download my Study of Loops demo here: https://forums.gamesalad.com/discussion/comment/371400/#Comment_371400. Use the timeStamp method. Within each iteration, check the table cell value as follows:

    Change Attribute self.cellValue [integer or index] to tableCellValue(tableName,row,column)
    When [attribute] self.cellValue = 0 --> stop the loop (in my example, you could change self.Counter to a large number or you could create your own boolean for this and add it as another condition of the loop rule).

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

  • galaseagalasea Member Posts: 17
    Thanks! I'll try it out and see if I can get it working :)
  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949

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

  • galaseagalasea Member Posts: 17
    Tatiang, I tried the timestamp loop with the awesome file you created, but I'm having difficulty getting the loop to trigger off of an action. Based off of ericzingeler's post, I changed the first rule to self.Time >= self.LoopintervalTime, then created a new rule that will change self.LoopintervalTime to self.Time + self.LoopDelay when touch has been pressed. Any suggestions on how to fix it? Thanks so much for your help!
  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    The timeStamp loop requires two rules, one to check the time and one to check the iteration status. If you wrap both rules in another rule (e.g. when attribute game.startLoop is true), and then add a rule When touch is pressed --> change attribute game.startLoop to true, it should work.

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

  • galaseagalasea Member Posts: 17
    Tatiang, I did exactly as you suggested, but the loop fails after only a single iteration (counter only gets to 2). From looking at debugging statements, it looks like on the second iteration, the first rule that checks the time completes and changes self.IterationComplete to true, but then the second rule of the loop doesn't trigger off of this, which is kind of baffling to me.

    This is basically what I did:

    Rule: When mouse is pressed and inside, change attribute self.Trigger to true

    Rule: When attribute self.Trigger is true
    Rule 1 of Loop (self.Time > self.LoopIntervalTime)
    Rule 2 of Loop (self.IterationComplete is true)
  • galaseagalasea Member Posts: 17
    Hmm, looks like formatting got messed up a bit in my previous post, but to clarify, Rule 1 of Loop and Rule 2 of Loop are inside Rule: when attribute self.Trigger is true
  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    @galasea That looks correct as long as self.Trigger stays true long enough for the loop to complete.

    If you'd like, you can send me a link to download your project file and I'll see if I can identify a problem.

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

  • galaseagalasea Member Posts: 17
    Thank you sooooo much, tatiang! Here's the link to my file: https://www.box.com/s/oqdi722qfvl11nec5etc. It's just a modification of the one you created.
  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    @galasea The file you uploaded is less than 1k. I don't think it worked. Try compressing the project file into a .zip file and then re-uploading it.

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

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    edited February 2013
    There's also a slightly simpler way to run a fast loop. It's in the mod1 Loop actor in that Study of Loops file.

    when self.mod1 > self.time%0.05
    .....action

    self.mod1 is a real attribute with a value such as 0.04.

    You can then wrap that in a When self.trigger is true rule.

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

  • galaseagalasea Member Posts: 17
    Whoops. Ok try this link now: https://www.box.com/s/qs8t64ali3joaivo4ciq
  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    Hmm... I see what you mean. I'm not sure why that loop isn't working with a condition (I even tried to wrap it in a When self.Time>3 just to test it and it did the same thing).

    I would suggest using the Mod1 Loop. It works fine with self.Trigger=true.

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

Sign In or Register to comment.