Reset all attributes

xactoxacto Member Posts: 146
edited November -1 in Working with GS (Mac)
Is there a simply way of reseting ALL attributes at once instead of changing each and every attribute separately?

Here is what is happening... when my player LIFE has reached "0" it goes back to the title screen, however when I hit "play" for the SECOND time all that stats/attributes and placed actors are where they were just before Life reached 0. I just want to reset EVERYTHING when it goes back to the tile screen.

I know I could just use the change attributes for each and every actor but that would take a long time... is there any other option?

Comments

  • CodeMonkeyCodeMonkey Head Chef, Member, PRO Posts: 1,803
    For now, the Change Attributes is the only way. Reset Game is something we're thinking about adding later.
  • xactoxacto Member Posts: 146
    Ok, here is a related question since there is no RESET.

    When I play my game the second time, the spawned Actors are in the same place when the player dies. So I thought I could include the following code. (basically removing all enemies from the field so I can spawn them in again from scratch)

    (Code is in the enemy actor)
    Every 1 second:
    Rule: When any conditions are valid: An attribute changes game.player.life equals 0 then Destroy this Actor

    I can not figure out how to delete these Actors that were spawned before I play again. Any ideas?
  • CodeMonkeyCodeMonkey Head Chef, Member, PRO Posts: 1,803
    Try without the Timer behavior. I think that when your life attrib is 0, and you play again, the life attrib is reset to non-zero before the Timer goes off.
  • xactoxacto Member Posts: 146
    I removed the Timer behavior and it still did not remove any of my enemy actors that were spawned from the first game.

    So... it looks like I can reset all my integers with Change Attributes like; score, shield and life however, any Spawned or placed Actors can not be changed or reset after it has been run once. (as far as I can tell)

    There is the "Destroy this actor" -- would it help if you could actually code the actor by name so the code could be entered someplace other then within the enemy Actor? (global integer?)
    ex: An attribute changes game.player.life equals 0 then Destroy enemyOne

    I am sure I am over looking something so obvious here, sorry... any help I would be grateful.
  • CodeMonkeyCodeMonkey Head Chef, Member, PRO Posts: 1,803
    What happens to the scene and player when the life attrib = 0? Does it immediately go to a different scene? Does it immediately change the life attrib back to full and spawns a new player at the original spot?
  • xactoxacto Member Posts: 146
    lets see... ok, when the life attribute reaches "0" I have the game change the scene to the Title Screen. I am able to change the Life attribute back to full, and the PLAYER will spawn at the original spot. I will upload the latest version to the game section and you can see what happens when you play it twice.

    Side note: It would be great to have the feature to upload documents on the forum so you can view my code.
  • CodeMonkeyCodeMonkey Head Chef, Member, PRO Posts: 1,803
    Ok so try this.
    You know that for the Start button, whenever it is pushed, your global(game) attributes need to be reset. So set your "Score" and "Player Life" there instead of in the Otherwise of the "Player"

    The title "Starfire" does not reset to its original size when you go back to the scene when you run out of lives. You can remedy this by adding a rule to it that resets its width and height when "Player Life" is 0.

    If you add a rule to the Player, all the enemies, and explosions that when "Player Life" is 0, destroy it, then that should clear the game scene of any spawned instances before you return to the scene.

    Finally, since you are restarting, you would need to spawn those first 6 enemies, since reset scene is not yet available. I would suggest that you create an actor that spawns when Player Life = 4. Or if you plan later to be able to gain life, then create an attrib that says that a new game has started, and toggle it at the same time as when Player Life =0 and when you reset Player Life.
  • xactoxacto Member Posts: 146
    THANK YOU, everything is working now!!!!! :)
  • xactoxacto Member Posts: 146
    ...that was until I BOMBED and did not save. (just when everything was working)

    So I recreated all the commands again. I thought it was working, but as soon as I tried to create SPAWN enemy actors (instead of placing them) they will not be destroyed when Player = 0.

    I enter the code in all enemy actors that if Player = 0 then destroy.

    It was working but now... no go.

    I uploaded a new version.
  • CodeMonkeyCodeMonkey Head Chef, Member, PRO Posts: 1,803
    A few things:

    The Title Scene Change Size in a Timer can be inconsistent. I suggest the Change Size in a Rule that activates when width is less than some set number.

    The initial spawn position of the enemies needs to be reset.

    Instead of having the change scene inside the Player actor that gets spawned, try adding it in something more static like the Initialize actor in a rule that checks if Player Life = 0, after .3 seconds Change Scene.

    Since Player Life is an integer, you can just check the condition that it is less than 1, instead of having 2 conditions checking if it = 0, or is less than 0.

    Instead of a timer within a timer, you could count how many enemies you spawn with an attrib in the initialize actor. When New Game is true and spawnedActors < 6, do the timer that spawns enemies and increment the number spawned.

    Also in the Initialize actor have a new rule that checks when the number spawned becomes 5 or 6. There you can reset the NewGame, number of enemies spawned, and the initial spawn location.
  • xactoxacto Member Posts: 146
    Thanks again... that fixed everything!!!! Looks like I went a little bit TIME happy there. It is starting to make sense now. ;)
  • ktfrightktfright Member Posts: 964
    I'm sort of having the same problem, is it possible to reset all attributes for my game also? i do not know if this applies to my DRFT game
  • CodeMonkeyCodeMonkey Head Chef, Member, PRO Posts: 1,803
    Right now you would need to use Change Attribute behaviors for each attribute that needs to be reset
  • ktfrightktfright Member Posts: 964
    Okay, I'll try that.
Sign In or Register to comment.