Reset Tables

3itg3itg Member, PRO Posts: 382
Copying Tables seems to take a long time...
When I start my scene, I copy a default values table to another table. I then use that table to populate another table.
So when the scene starts, I need both Tables to be in a default state.
I was looping through, and changing the values back to default manually, but it took too long.

So I got the idea to make 2 tables with the default values for those tables in them, and instead of looping, just copy the default tables to the "instanced" tables at the start of the scene I need them in.
Seemed to be close, but I could not get it to work 100%.
So then I moved the copy table behaviors to the loading screen, and to the planet menu, which is another scene that the player will visit often.
This worked fine, but if the player dies, they dont start in either of those scenes.
So I added the CopyTable behaviors to the scene, and I made some conditional statements, that check to see that the table has default values by checking the value of the last cell of the last row, once the conditions are met, the process continues assuming the table was populated.
It continues, but the table has not finished being copied. The first 2-3 actors that attempt to access data in that table fail with out reason.
I check the values of the failed actor, and they are exactly what they need to be, in order to continue.
So I added a boolean, that flips to true if the data in that row of cells is ready... and when I am done populating each row, I switch that boolean to true.
It works on all of the actors spawned after #3.
1,2 and 3 just never flip the boolean, although the conditions are met.
Or flipping the boolean is so slow, that the other actors already have read it as false.




if I do the copyTable in another scene, then switch scenes, it seems to be fine for the most part (still fails every once and a while, but I havent gotten to tracking that down yet.).

Does anyone have any experience with the time it takes to copy a table?
or based on my description, see where I may be going wrong?

I can explain further, in more detail, or upload a video if it will help to illustrate the problem.

Comments

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    I think the Copy Table behavior is probably not the problem here.

    As an example, here's a file that copies an 88,000 row table when you click the actor. It then displays the time it took to check the last row for the correct entry. It's under a tenth of a second.

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

  • 3itg3itg Member, PRO Posts: 382
    @tatiang
    Yup, I check the last row for the correct entry (it's 6 rows) and it passes that validation very quickly.
    The actor that gets it data from row 6 never fails, so the last cell is good.
    Its always the actor accessing data from the first cells, in the first row. (16 columns)

    Are they populated in decending order or something?
  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    Maybe... I don't really know.

    Here's a version where you can set a game attribute for any row you want. I tried it with row 1 with the same large table and it was just as fast, maybe faster.

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

  • 3itg3itg Member, PRO Posts: 382
    @tatiang
    Thanks for the effort with the examples.
    I think the discrepancy may lie with the fact that in the example, there is no other processing being done.
    But it did answer the question as to how long it SHOULD take.

    So with that in mind, is there a way that I can be sure that my copy table behaviors are the absolute first thing to be executed upon entering the scene?
  • 3itg3itg Member, PRO Posts: 382
    I moved the copy tables above my constraints and it worked... turns out which 1/10th of a second it took place was very important.
Sign In or Register to comment.