Combine data from 50 database rows?

awhedbeeawhedbee Lakeland, FlMember, PRO Posts: 5
edited February 2016 in Working with GS (PC)

Hello,

I have a question. I'm still pretty new to gamesalad and wondering the easiest way to combine the values from 50 database rows. Basically each level saves the highscore to the row (which is the level number) and then column 5.

So I need to combine the score from "Column 5" from "Rows 1-50" and then display it as "Bits Recovered"

"Bits Recovered: "..tableCellvalue((game.Table 1), 1 , 5)

It will display row 1 column 5 but I cannot get it to add them all together. I am trying to find more documentation on the "tablecellmerge"

Thank you for any help!


Comments

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

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

  • awhedbeeawhedbee Lakeland, FlMember, PRO Posts: 5

    Awesome thank you so much

    I've got it merging now is there a way to add them all together easily?

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

    Oh sorry, I forgot that you needed to sum them. The only way to do that is with a Loop (or Loop over Table if PC Creator has that behavior):

    Loop while self.rowIndex < tableRowCount(tableName)
         Change Attribute self.rowIndex to self.rowIndex+1
         Change Attribute self.sum to self.sum+tableCellValue(tableName,self.rowIndex,5)

    If self.rowIndex = tableRowCount(tableName)
         [Loop has completed]

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

  • awhedbeeawhedbee Lakeland, FlMember, PRO Posts: 5

    Awesome Thank you

  • GeorgeGSGeorgeGS Member, PRO Posts: 478

    Seems like tableColSum would sum them for you without the overhead of an external loop and extra complicated syntax.

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

    @GeorgeGS said:
    Seems like tableColSum would sum them for you without the overhead of an external loop and extra complicated syntax.

    Even better.

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

Sign In or Register to comment.