TableColSum but no TableRowSum
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
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)
i made a picture to clarify the issue i have a bit better
@DeepBlueApps
You use tableColSum for both columns and then just add those values together
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?
You can make your own:
@tatiang
great! thank you very much
thats exactly what i was looking for
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
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
Sorry, I don't understand either of these sentences.
@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
Glad to hear you got it working!
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.
yeah its good to know this for the future.
"Align everything as columns (downwards) so it can be summed by the function."