TableColSum, how long does it take.

I have 3 tables, 320 columns in total. And all these columns need to be summed everytime players open the game.

What I did is, I used TableColSum to change 3 game level attributes, Sum1=TableColSum for Table 1, Sum2=TableColSum for Table 2 and Sum3=TableColSum for Table 3. And then when the game enters the main scene, these 3 attributes are added together.

The problem is, I delay the splash screen (where TableColSums are) by 10 seconds, and it seems that the function does not seem to work. It did return return some values though, but a negative value (all values in columns are positive).

My question is, is there any ways to check whether the calculations (TableColSum) have been done up to the last columns? Do 10 seconds is not llong enough to sum 320 columns from 3 tables?

Comments

  • pokapolapokapola Member Posts: 143

    Oh just to add, I did think of summing up all the columns manually,by incrementing n, and the sum it up by adding game.SumTable+TableCellValue(Table,n,1) but is just seems to be a good waste of the TableColSum function.

  • JSprojectJSproject Member Posts: 730

    Doing such a calculation should only take a fraction of a second so there is something wrong with your logic. Try this: after the sum1, sum2, sum3 that calculates the TableColSums then add a 0.2 sec delay before you're doing sum4=sum1+sum2+sum3.
    Add some display text to the scene that shows the values from the four attributes (game.sum1 etc) so that you can see the values directly (for debugging purpose)

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

    Are you using a Loop or some other method to sum all of those columns? It may be that you're not letting the loop finish. You may also have an error in your tableColSum expressions. Can you post them? You should be able to copy and paste from the expression editor (at least on a Mac).

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

  • pokapolapokapola Member Posts: 143

    I ditched the TableColSum function, and sum all the columns in all of the tables manually, it works, I did not alter any existing logic except for adding Loops behaviours and deleting the TableColSum.

    Don't know what's wrong with TableColSum

  • MarcMySaladMarcMySalad Member Posts: 158

    @pokapola said:
    I ditched the TableColSum function, and sum all the columns in all of the tables manually, it works, I did not alter any existing logic except for adding Loops behaviours and deleting the TableColSum.

    Don't know what's wrong with TableColSum

    There is nothing wrong with TableColSum I use it all the time

  • zweg25zweg25 Member Posts: 738

    Make sure you are not using a row out of bounds of the table in the tableColSum function. Also it will run much faster than summing each value manually

  • ArmellineArmelline Member, PRO Posts: 5,354

    If you try to run tableColSum on 320 columns simultaneously, it'll not happen instantly. (Nothing being done 320 simultaneously will.) That said, 10 seconds should be way more than you need to do that. I'd definitely be checking what @zweg25 mentioned first.

    Perhaps post a sample table (same number of rows and columns, can be random numbers in it) here so people can run quick tests of their own.

  • pokapolapokapola Member Posts: 143

    Guys, I have ditched the TableColSum function, and I sum all the rows manually instead, and it works just like it should work.

    I don't know it didn't work with TableColSum, maybe it's a bug?

  • JSprojectJSproject Member Posts: 730

    @pokapola said:
    Guys, I have ditched the TableColSum function, and I sum all the rows manually instead, and it works just like it should work.

    Good for you

    I don't know it didn't work with TableColSum, maybe it's a bug?

    Or maybe it's just your logic since everyone else in this thread seems to have no issue with it?

  • ArmellineArmelline Member, PRO Posts: 5,354

    @pokapola said:
    I don't know it didn't work with TableColSum, maybe it's a bug?

    Possible, but most likely is you were using TableColSum slightly wrongly, as @JSproject says. 19/20 it's a logic issue rather than a GS bug :D

Sign In or Register to comment.