Reset Variables Question.....

luke2125luke2125 Member, PRO Posts: 225

Hi,

I have a question regarding resetting variables, which is driving me nuts......!!!!!!!!! Ok, I have a Table with Integer Variables that I use throughout the game ( ex: health, score ). Therefore, I reset these variables by using Change Table Behavior, since the variables are in a Table. Then I start the game, everything is fine, however, since I don't want to save the Table, I'm just updating the variables that need to be updated, and the rest I leave alone, so I don't need the save table behavior, since they are being saved without being updated. Ok, hope I don't sound confusing....Therefore, the game starts, everything fine, the game ends or it's over then lives = 3, once it's reached I go to the Game Over Screen, therefore, I press button and go to Menu, and start again the game, my variables are still there, especially the lives ( being reset ), score ( not being reset ), health ( being reset). Now, for some unknown reason which is driving me nuts!!!!!!, after a while on the game, the score, health variables stop being updated....In other words, they don't register ( ex: player hits obstacle, score + 1, just like health, health -5 ). They just stop updating. Does anybody know what can cause this? Should I use global variables or self variables instead of variables in Tables? Sorry, but I just love Tables.....:) What do you think? Has anybody experience this from their game? And no, I can't reset using Reset Game variables, cause it will reset all the variables, I'm resetting variables manually, just the wants i need. Well, hope someone can give me any insights......Thanks and God Bless....

Sincerely,

Sunday

Comments

  • KevinCrossKevinCross London, UKMember Posts: 1,894
    edited April 2016

    If you want to use tables to store attributes and have a set of variables that can be reset all the same time then you could do what I do when I want to reset a table and that's have two tables. One with your data structure in with MASTER at the end of the table name and a completely blank table with the same name without MASTER in the name.

    Whenever you want to reset the table and everything in it you just copy your master table to the blank one.

    Here's what I mean:

    TableName: "Game Attributes MASTER"
    This table contains rows and data for the starting lives, health, coins and whatnot

    TableName: "Game Attributes"
    This table is completely blank. It doesn't even need column headers in it.

    At the start of a new game do:
    Copy Table: "Game Attributes MASTER" to "Game Attributes"

    Then write your data to the "Game Attributes" table during gameplay.

    I do this two table approach alot as there's no easy way of just resetting a table. I don't use tables for Game Attributes though. Have considered it but would get bored of writing tableCellValue every single time.

    I can't answer your question about why the table isn't always updating during gameplay, other then double checking that the code is correct in each place and triggers at the correct time.

  • luke2125luke2125 Member, PRO Posts: 225

    Hi Kevin,

    Thanks for the help......:) However, I did tried your suggestion, and still no go. The thing is that when I start the game, everything works fine, however, when I go to another scene which is the Game Over Scene, I press the Menu Button, in which I have a Change Table Behavior row = 1 column =18 Value = 0. From there, go to Main Menu, I press the Play Button, in which I have a Behavior where If Button Press and Table = 0 , then Change Reset some values for the Table. Start playing the game, and it starts working, but after like seconds, the score, health, and lives left don't update, as I play the game. I'm going to post a youtube video of the actual game play so you can see.....God Bless....

    Sincerely,

    Sunday

  • luke2125luke2125 Member, PRO Posts: 225

    Hi Kevin,

    The variables are changing or just the ones I need, the problem lies, that when I collide with objects, it's not recognizing the collision and deducting or adding from the respective variables......God Bless.....

    Sincerely,

    Sunday

Sign In or Register to comment.