TableColSum but no TableRowSum

BigDaveBigDave Member Posts: 2,239
edited January 2015 in Working with GS (Mac)

As I found out I can create a sum within a table by using TableColSum
but I miss the same option for Rows.

Do I overlook it or is it not there?

Goal:
I have highscore value considering table values (in a row)
based on the unlocked levels.

Here the case in detail:
Pseudo code:

Table Values:

Level 1(row1) gives 1 score

Level 2(row2) gives 3 score

Level 3(row3) gives 5 score

Level 4(row4) gives 10 score

Player has unlocked 2 of 4 levels

Highscore = table row sum(row1 to Amount.LevelsUnlocked)

How would I circle through the relevant rows without TableRowSum

Comments

  • UtopianGamesUtopianGames Member Posts: 5,692
    edited January 2015

    The column sum will count based from where you start and finish the rows Dave.

    tableColSum(table,col,startRow,endRow)

    If you have 5, 10 and 15 in rows 1-3 it will return 20 5+10+15

    tableColSum( game.YourTableName,1,1,3)

  • BigDaveBigDave Member Posts: 2,239
    edited January 2015

    i made a picture to clarify the issue i have a bit better
    @DeepBlueApps

  • MarcMySaladMarcMySalad Member Posts: 158

    You use tableColSum for both columns and then just add those values together

  • ArmellineArmelline Member, PRO Posts: 5,421

    I'm really not clear on what you're asking. Could you try explaining it again? Why are you needing to add? Why can't you just... add them? :D

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

    You can make your own:

  • BigDaveBigDave Member Posts: 2,239
    edited January 2015

    @tatiang‌
    great! thank you very much
    thats exactly what i was looking for

  • BigDaveBigDave Member Posts: 2,239

    sptill lacking some key things here.
    How would I say this function now which row it should check
    I can picks start at end cell within either a row or a column

    But if i want to circle through columns of a specific row
    how would i do that

    how ever i gonna do differently to avoid that table work and just make IF level
    add this cell to highscore

  • zweg25zweg25 Member Posts: 738
    edited January 2015

    So there is not a tableRowSum function (probably because if one column is text and one is an int it'll break the game). What I would do is make a loop with a self.column attribute and say:

    While self.column is less than game.levelsUnlocked - If you do not have a game.levelsUnlocked then you can do tableColCount(game.table)

    change attribute game.score to game.score + tableCellValue(game.table, 8, self.column) - where 8 is just the row that you pick to go through

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

    @BigDave said:
    How would I say this function now which row it should check
    I can picks start at end cell within either a row or a column

    But if i want to circle through columns of a specific row
    how would i do that

    Sorry, I don't understand either of these sentences. :\

  • BigDaveBigDave Member Posts: 2,239

    @‌zweg25
    thanks!

    @tatiang‌
    jeah tables always scared, this seem to effect even my communication (its a blur in my mind)
    But it works now so thank you guys

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

    Glad to hear you got it working!

  • jonmulcahyjonmulcahy Member, Sous Chef Posts: 10,408

    @zweg25 said:
    So there is not a tableRowSum function (probably because if one column is text and one is an int it'll break the game).

    i think this is the exact reason. You can always guarantee that a column will contain the same data types. A row could be comprised of many different column types, and would break the function.

  • BigDaveBigDave Member Posts: 2,239

    yeah its good to know this for the future.

    "Align everything as columns (downwards) so it can be summed by the function."

Sign In or Register to comment.