I Give up - Wheres the explanation on 'Loop over table' behavior

StormyStudioStormyStudio United KingdomMember Posts: 3,989
edited March 2014 in Working with GS (Mac)

Loop over table' behaviour, Wheres the official documentation? …. I know it was released with the first nightly it appeared with.

I've searched using google and find nothing, the forum search, nothing but year old threads that were written before the new behaviour, tried looking through cookbook, manuals, searching for the old text doc, for the old nightly thread… I've tried searching for someones tutorial (sorry can't remember who it was that had made a few useful tuts on these).

It's a tad frustrating as I've spent a good hour searching for a tiny explanation… and just want to see if the behaviour will do what I'm looking to do before I make a more involved rule setup.

The short explanation along side the behaviour in creator isn't sinking in…

I'd of thought it would be given out again with the Release candidate thread for users new to it.. but not seeing it there.

Admittedly I am tired.. but then I've been tired for about 4 years so that shouldn't be a problem.

Please put me out of my misery… I'm sure the info is blatantly in front of me.

Comments

  • SlickZeroSlickZero Houston, TexasMember, Sous Chef Posts: 2,870
  • StormyStudioStormyStudio United KingdomMember Posts: 3,989
    edited March 2014

    Thanks but it was the 'loop over table' behaviour I was interested in, not just the 'loop' behaviour. just wanted to see if it could be used to loop through the columns of a given row of a table to copy the row to another table.

    I know I can do it with a rule and a loop but thought the loop over table might yield some performance improvements

    I kinda found the doc I was looking for, but it only has info on the new table functions, not the loop behaviours… which must have been in an earlier nightly…

    http://gsdc.gamesalad.com/2014/01/30/17/19/52/28/NewFeatures_JS_v5.pdf

    The search continues…

    Anyway… It seems a little odd that the above linked doc and also 4 videos which explain the new table and text string functions aren't easier to find . They were posted along with nightly thread 0.0.0.221
    http://forums.gamesalad.com/discussion/63756/nightly-build-0-0-0-221-is-up/p1

  • Braydon_SFXBraydon_SFX Member, Sous Chef, Bowlboy Sidekick Posts: 9,273

    Hmm. So what you're trying to do is search for a row, then copy that row? If so, you could use the new tableSearch function...?

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    edited March 2014

    Here's a Release Candidate demo that concatenates (joins) letters from table rows into a single text attribute using a Loop over Table behavior: https://www.dropbox.com/s/rewt896rje3wvde/Loop over table demo RC.zip. Loop over Table runs any embedded behaviors* on each row or column of a table.

    The Loop Over Table behavior takes 6 inputs:
    1. Table name (should be self-explanatory) 2. rows or columns: loop through rows or columns. To check every row of a single column, choose rows. 3. Start index: the row or column number to start looping. 4. End index. the row or column number to end looping. 5. Store index in Attribute: an integer attribute that will contain the current row or column number within the loop process. 6. The rules or behaviors* that will run during each loop iteration.

    *There is a list of behaviors that will not work as part of a Loop over Table behavior. These can be found by clicking on the behavior in the Behaviors Library in Creator.

    Here is a screenshot of the Loop over Table behavior from the demo:

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

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

    I just tried to copy selected table columns and I couldn't get it to work. Not sure why. Maybe the loop is too fast for Change Table Value behaviors, but it shouldn't be.

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

  • The_Gamesalad_GuruThe_Gamesalad_Guru Member Posts: 9,922

    I forgot about this behavior. I can use this! Hmmm time to experiment. So much new stuff I can't keep up!

  • StormyStudioStormyStudio United KingdomMember Posts: 3,989

    Thanks for the replies.

    So it's a slightly tidier way of stepping through rows/columns in a table but doesn't actually read the data in the cells, just uses the number of rows/columns.

    I was doing this before with a rule that would add 1 to an attribute until it reach a given number (or equal the TableNumberRows/Columns Function)… on each pass you could do what ever you wanted… So it seems identical.

    With 'Loop Through Table' you still have to use an attribute to note which row or column number your at in the loop so the advantages are a tidier interface, and maybe speed (?)…

    is that it, or am I missing something?

  • HopscotchHopscotch Member, PRO Posts: 2,782
    edited March 2014

    It is a tidier/compact way of doing it,

    but no speed improvement, each cycle still takes up at least one frame draw, i.e. ~0.01 seconds.

    The TableSearch however is fast, not tied to cycles.

  • HopscotchHopscotch Member, PRO Posts: 2,782
    edited March 2014

    @tatiang, related to the issue you found:

    It is important to note that the "Loop over Table" behaviour does not execute in oder of your code, but in parallel, as it cycles one frame at a time.

    The following example copies the contents from column 2 to 3. The last log debug statement will in this case still report a blank column 3 in row 5 because the loop has not reached that row when the log debug displays.

    Putting the last statement in a timer (after x seconds) would give the expected result.

  • UtopianGamesUtopianGames Member Posts: 5,692
    edited March 2014

    Table search is like lightning....honestly nearly fell off my chair when I 1st ran some tests.

    In my Mr Bomber game I'm using a table with 4 columns easy-extreme and using integers 0 locked 1 open and 2 completed so it comes in real handy to find an open level, when you complete a level it unlocks the next difficulty along with the next level same difficulty so it's possible to skip and go back but then you have to work out where the next open level is (basically search for a number 1)...easy with this feature.

    I've also used table search to know when you have completed all the levels (all cells are 2) to go to the end scene.

    Darren.

  • StormyStudioStormyStudio United KingdomMember Posts: 3,989

    Hey Darren .. @‌DeepBlueApps

    You're talking about the 'table search' function right? … not 'Loop Over Table'

    Yet to use that but will definitely be using it soon and look forward to seeing the blazing speed..

  • UtopianGamesUtopianGames Member Posts: 5,692
    edited March 2014

    Yes m8 I also found loop (not loop over table) unreliable when trying to search for an integer with a method like...loop while tablecellvalue, self row, self column #1, it misses for me and I need 2 ones in a row for it to catch the second one and stop looping. It's no big deal because as always there's various ways to do things so all good.

    Darren.

Sign In or Register to comment.