GameSalad

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Combine data from 50 database rows?

awhedbeeawhedbee Lakeland, FlPosts: 5Member, PRO
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 Posts: 11,714Member, Sous Chef, PRO, Senior Sous-Chef

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

  • awhedbeeawhedbee Lakeland, FlPosts: 5Member, PRO

    Awesome thank you so much

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

  • tatiangtatiang Posts: 11,714Member, Sous Chef, PRO, Senior Sous-Chef
    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, FlPosts: 5Member, PRO

    Awesome Thank you

  • GeorgeGSGeorgeGS Posts: 478Key Master, Head Chef, Member, PRO GameSalad Employee

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

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

    @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.