Copy Table Behavior not working

KaiWenKaiWen Member, PRO Posts: 93
edited July 2012 in Working with GS (Mac)
I have a table called "TB Questions" and "MasterTable" They both had 109 rows. I removed 1 row from the "Tb Question" table. On my actor that I have to click to start the game I have the following

When Actor Receives Touch is Pressed
Copy Table
Copy: MasterTable
To: TB Questions

I run the game. Click the actor to start and when I look at the " TB Questions" table, I still have only 108 rows. Shouldn't I have 109 rows?

Best Answer

  • KodeRiter722KodeRiter722 Posts: 42
    Accepted Answer
    Its actually doing exactly what it should! :P The table is being saved persistently. If the user was to turn their game off and turn it back on that table would be saved with 3 rows and 5 columns. You will never see the actual table values changed in your gamesalad program. that's not the way it works. when you exit the preview that is not equivalent to the user restarting, that is equivalent to a completely fresh installation of the game. if you are looking to make a copy of a table to actually see in gamesalad, you need to do what the user above mentioned and copy the csv file.

Answers

  • HC_DKHC_DK Member Posts: 92
    When you copy a table it is only during "game play" and not the table you will see in the TABLES section in GameSalad.

    But you can check inside GS that it is working by displaying the tableRowCount.

    HC
  • KaiWenKaiWen Member, PRO Posts: 93
    Hi @HenrikChristensen thanks for the reply. I don't understand. I have two tables that I created. TB Questions will have rows deleted\removed as the user plays the game.

    The MasterTable will (or needs) to be copied to the TB Questions every time the user starts the game or replays the game.

    I have the copy action on a actors receives touch is pressed (event)

    Nothing happens. I manually deleted a row from the TB Questions table so I could make sure that the copy table action was working and the rows count would be equal in both. My TB Questions table is not over ridden by the MaserTable.
  • HC_DKHC_DK Member Posts: 92
    KaiWen: I don´t know what you are doing wrong because I have just made a simple test.

    I made two tables. First one called Master with 5 ROWs and 3 COLs, the second is called Copy and only has 1 ROW and 1 COL.

    Then I made an actor to show the ColCount and RowCount for Master showing: 3:5 and one actor showing the same for the Copy table showing: 1:1.

    An actor with a rule: when pressed - copy Master to Copy.

    When that is done the Copy ColCount and RowCount shows: 3:5.

    You can download a copy of the GS-project here: http://dl.dropbox.com/u/12878764/Copy_Tables.zip

    HC
  • KaiWenKaiWen Member, PRO Posts: 93
    @HenrikChristeen it's really puzzling. I even turn off the other actions in the actor just to see as a test to make sure that my rule was firing. Turn off attribute action to start the game when pressed. Keep the table copy attribute action turned on. Run the program. Click the actor. game does not start. Check the tables. The TB Question is not updated.

    I then turn back on the attribute action to start the game when the actor is clicked. Run the game. Check my TB Question table. Still no change in the number of rows.

    I can't figure it out. I tried to post a picture of the rule, but I see that I have to have the picture hosted somewhere first. I'll try to do that in a few minutes. The copy table action looks super simple, but it is not working.

    Thanks so much for all your input. I greatly appreciate it.

    Kai
  • HC_DKHC_DK Member Posts: 92
    @KaiWen: Send your file to me hec_chr@hotmail.com and I will take a look at it.

    HC
  • KaiWenKaiWen Member, PRO Posts: 93
    Hey @HenrikChristensen here is a image of the rule that is being used. The "Copy Table" action is not firing from what I can see.

    image
  • KaiWenKaiWen Member, PRO Posts: 93
    I'm gonna try you demo to see if it works for me.
  • KaiWenKaiWen Member, PRO Posts: 93
    @HenrikChristensen okay I ran your code and it works like a champ. I see the labels change to reflect how many rows and columns are in the Copy Table. Now, when I stop the program from running your Copy Table reverts back to it's original state. Am I missing something?
  • HC_DKHC_DK Member Posts: 92
    @KaiWen: As I mentioned in my first reply, copying a table when your "game/program" is running will NOT copy the table in GameSalad TABLES section.

    If you want a copy of your Master table export it to .csv and import to your copy table.

    HC
  • KaiWenKaiWen Member, PRO Posts: 93
    @HenrikChristensen when I read the description for the Copy Table action is says " This behavior will copy the specified table in its entirety to the target table. Meaning, no matter that the contents of the target table, it will be completely overwritten by the source table"

    Am I missing something? I know how to export and import the csv files.
  • KaiWenKaiWen Member, PRO Posts: 93
    Okay let me rethink this. I just tried a "Save Table" action on the Copy table in your demo after the "Copy Table" action. The "Copy Table" still reverts back to it's original state. This is looking to me as if the "Copy Table" action is only creating a copy of the table during runtime.

    Is that how it's suppose to work? It's kind of like a temp table in SQL or a collection in c# or vb.net. That is what it looks like based on how it's working for me. I would have thought the "Save Table" action would have made that data in "Copy" table look just like the "Master" table. is this only during runtime that the data gets copied from one table to another table?
  • HC_DKHC_DK Member Posts: 92
    Yes, only during runtime...
  • KaiWenKaiWen Member, PRO Posts: 93
    http://cookbook.gamesalad.com/tutorials/2/parts/36

    I'm trying to used the Copy Table action just like how it's described. To reset some quiz questions.
  • KodeRiter722KodeRiter722 Member Posts: 42
    edited July 2012
    Save Table will persistently save any table...even one which is a copy of another table. Use the Save Table behavior if you would like to save the values in the Copy table even after the user exits and returns to the app.

    Immediately after copying the table, use a Save Table behavior on the TB Questions table. That will solve your problem. so it should look like this:

    -When Actor Receives Touch is Pressed:

    -Copy Table
    -Copy: MasterTable
    -To: TB Questions

    -Save Table
    -TB Questions

    Let me know how that works for you....
  • KaiWenKaiWen Member, PRO Posts: 93
    How can I add a download like to a file from my dropbox account? I modified the file from @HenrikChristensen and want you guys to give it a try.
  • KodeRiter722KodeRiter722 Member Posts: 42
    put it in your dropbox's "Public" folder. find the file in your dropbox folder, right click it, select Dropbox > Copy public link. Then paste that link in here or pm it to us. once it finishes uploading we will be able to access it.
  • KaiWenKaiWen Member, PRO Posts: 93
    Oh Okay. I tried that. The link did't look like a clickable like. Here it is again. https://dl.dropbox.com/u/69168370/Copy_Tables_ver2.zip
    This is a copy of the demo that @HenrikChristensen did and I modified.
  • KaiWenKaiWen Member, PRO Posts: 93
    I've uninstalled gamesalad and reinstalled the program to see if it would make any difference. I would love to hear how this works for you.
  • KaiWenKaiWen Member, PRO Posts: 93
    Dang!! Okay @KodeRiter722 you are so RIGHT!! I see what you mean. ^:)^

    THANKS so very much to all you guys!!
Sign In or Register to comment.