advice for displaying table row values in game

goonergooner Lancaster, PAMember Posts: 135

If at the end of a level, I would like to display rows of stats (for the just completed level) that come from a table. Right now I'm thinking I might need to spawn an actor for each row i would like to display and also use a loop since I only want to show records where column level = (whatever number level just completed).

Before I get too lost on my own, I wanted to check and see if there's a common approach to this.

I have seen a few previous posts but wasn't sure those are doing exactly what I am looking for. If there is an existing post for this please link if not too much trouble and easily found.

Thanks!

PS - as always, really appreciate the practical advice and techniques as it's kept me going to finish one working level.

Comments

  • The_Gamesalad_GuruThe_Gamesalad_Guru Member Posts: 9,922

    You can put them all in one actor and with a series of display texts in that actor use the position controls for each text attribute to lay them out how you want.

  • goonergooner Lancaster, PAMember Posts: 135

    @Lost_Oasis_Games said:
    You can put them all in one actor and with a series of display texts in that actor use the position controls for each text attribute to lay them out how you want.

    Going to try this later, thanks!

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

    @Lost_Oasis_Games said:
    You can put them all in one actor and with a series of display texts in that actor use the position controls for each text attribute to lay them out how you want.

    Crap. Why didn't I think of that? :s My word game would benefit from removing the few dozen actors on the student record screen and replacing them with a single actor. That's what I get for working on an app for... two years. Lol!

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

  • The_Gamesalad_GuruThe_Gamesalad_Guru Member Posts: 9,922

    @tatiang said:
    Crap. Why didn't I think of that? :s My word game would benefit from removing the few dozen actors on the student record screen and replacing them with a single actor. That's what I get for working on an app for... two years. Lol!

    Hey I am the guru you know ;) I just play Clark Kent on the forum :)

  • goonergooner Lancaster, PAMember Posts: 135

    Has anyone had any luck displaying text inside a Loop Over Table?

    I am trying this inside the loop:

    the Store Index in Attribute is self.rowNum

    Text: tableCellValue(tableName, self.rowNum, "ColumnName")
    V-Position: self.RowNum * -20

    No luck...

    If I drag this Display Text out of the loop, it displays the last row's value.

    Is it possible to Display text in a loop then?

    Thanks!

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

    Loops are so fast that it wouldn't make sense to display text with them. Loop Over Table is great for searching through cells, tallying cell data, summing cell data, etc. Is there a reason you want to loop and display at the same time?

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

  • goonergooner Lancaster, PAMember Posts: 135

    @tatiang said:
    Loops are so fast that it wouldn't make sense to display text with them. Loop Over Table is great for searching through cells, tallying cell data, summing cell data, etc. Is there a reason you want to loop and display at the same time?

    I was hoping to use display text to show data from table rows. The table is used as a log to record when the player earns points. I want to show the player what was recorded at the end of each level.

    Since, the amount of rows can vary, I figured I would have to use one display text inside a loop over table. The idea was that this would display each row from the table using the stored index as the row number as it looped thru the records.

    Is there a way to display text when you don't know how many rows you will be displaying?

    Should be ...
    1) clear all rows in the table
    2) add a row into the table each time player earns points
    3) player completes level and the log appears
    4) log displays text for each row in the table (row count unknown until level is complete)

    Thanks!

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

    I still don't get it... why are you displaying text for every row in the table? Wouldn't you just want to display a single row based on the level number? If you want to display a bunch of rows at once (not scrolling quickly through the data), you'd need several actors or one actor with a bunch of display texts.

    Or do you want it to quickly scroll through the data (e.g. show one row's data every split second, almost like a text animation)???

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

  • goonergooner Lancaster, PAMember Posts: 135
    edited October 2015

    Sorry for unclear explanation, here is an example …

    Level 1 the player has 3 battles.

    The log should be...


    1 – Win, 100 pts, x2 multiplier, 200 total
    2 – Loss, 0 pts, x2 multiplier, 0 total
    3 – Win, 300 pts, x1 multiplier, 300 total


    Level 2 the player has 7 battles.

    The log should be …


    1 – Win, 100 pts, x2 mutiplier, 200 total
    2 – Win, 250 pts, x1 multiplier, 250 total
    3 – Win, 300, pts, x2 multiplier, 600 total
    4 – Loss, 0 pts, x2 mulipler, 0 total
    5 – Loss, 0 pts, x1 multiplier,0 total
    6 – Win, 500, pts, x2 multiplier, 1000 total
    7 – Win, 600 pts, x4 mulipler, 2400 total


    My goal is to show the results from each battle in the level that was just completed, but I will not know how many until they complete the level. It might take 1 battle or 10 battles. I do not want any motion or animation in the log, just to show the results that come from the table rows so they can see a detailed summary.

    Thanks for any help!

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

    Makes perfect sense now! :)

    For that, I would Loop Over Table and spawn an actor within the loop. The actor would have a Display Text behavior that displays all of the column data (e.g. win/loss, points, multiplier, total). To "pass" the row number to the spawned actor, use a game attribute for the loop index (e.g. game.row) and then have a Change Attribute behavior at the top of the actor that changes its own self.row to game.row. This will basically increment the value of self.row for each actor that spawns. Then use self.row to display text with TableCellValue() within the prototype actor's rules.

    For the text position in the actor, use a multiple of self.row. For example, for the Y position you could have 400-40*(self.row-1), relative to scene. So the first spawned actor would be at self.Position.Y=400, the second at 360, the third at 320, etc.

    If you can't get it working, let me know. I can probably put together a demo.

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

  • goonergooner Lancaster, PAMember Posts: 135

    OK, I follow this. I will try later, thanks again!!!

Sign In or Register to comment.