Triggering an event multiple times with an attribute

In my game, I want a comet to fly by once every time the game.Wave=1.

I can get it to trigger only the first time, but after the hero dies and the wave is reset, it does not recur.

Basically what I want is to trigger EVERY time the Wave=1.

This should be so simple. I thought every time an attribute changes, rules relying on that attributes will be retested. Is this normally the case is there an exception to that?

I'd appreciate any advice or answers.

Best,
Chris

Comments

  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598

    @CSharpMin Hi Chris, are you sure you're setting Wave back to zero immediately the hero dies? Literally at the end of the dying Rules of the hero actor, before changing any scenes, or restarting anything, etc., just put Change Attribute game.Wave=0. See how you go with that.

    ""You are in a maze of twisty passages, all alike." - Zork        temp domain http://spidergriffin.wix.com/alphaghostapps

  • stackpoolestackpoole Melbourne, Victoria, AustraliaMember, PRO Posts: 473

    @CSharpMin Hi Chris, are you sure you're setting Wave back to zero immediately the hero dies? Literally at the end of the dying Rules of the hero actor, before changing any scenes, or restarting anything, etc., just put Change Attribute game.Wave=0. See how you go with that.
    Or maybe add a timer before than, like After 0.1 Seconds [run to complettion]
    change atrivute game.wave=0

    sometimes ive noticed, that the attribute never reaches 1 but instantly changes to 0.

    Sydney Swans 2014!!

  • CSharpMinCSharpMin Member Posts: 12
    Thanks for your suggestions, but the wave is successfully going back to zero.

    game.Wave is an integer that steps up based on the player's score throughout gameplay, representing a wave of attack. It resets to zero not when the player dies exactly, but rather, after the reset button is pressed and before a difficulty is selected. After the difficulty is selected, game.Wave is set to 1 and gameplay begins.

    The Wave is always displayed on the screen, and seems to be correct.

    For testing purposes, instead of repeating every wave 1, I tried repeating the action every 8 seconds with a timer. It worked fine, so I know the actor is resetting to start position correctly. Now if I could just get it to work every wave 1.

  • CSharpMinCSharpMin Member Posts: 12
    bump
  • CharlieG97CharlieG97 Member Posts: 52
    Thanks for your suggestions, but the wave is successfully going back to zero.

    game.Wave is an integer that steps up based on the player's score throughout gameplay, representing a wave of attack. It resets to zero not when the player dies exactly, but rather, after the reset button is pressed and before a difficulty is selected. After the difficulty is selected, game.Wave is set to 1 and gameplay begins.

    The Wave is always displayed on the screen, and seems to be correct.

    For testing purposes, instead of repeating every wave 1, I tried repeating the action every 8 seconds with a timer. It worked fine, so I know the actor is resetting to start position correctly. Now if I could just get it to work every wave 1.

    Try this:
    Rule
    Every 0 seconds
    If game.wave = 1
    Spawn actor comet

    The timer will constantly check if game.wave = 1 and will spawn a comet as soon as it hits 1.
    Hope that works.
  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    edited December 2013
    I thought every time an attribute changes, rules relying on that attributes will be retested. Is this normally the case is there an exception to that?
    Yes and no. When an attribute changes value, the rule is retested but only triggers an action (e.g. behavior) if the state of the rule has changed.

    So if you have the following rule:

    When game.Number>5
         change attribute game.reachedSix to game.reachedSix+1

    And game.Number changes from 5 to 6, game.reachedSix will increase by one because the rule state was false but is now true.

    But if game.Number then changes from 6 to 7, nothing will happen because the rule state (true) hasn't changed. You'd have to change game.Number to, say, 3 and then back to 7 for game.reachedSix to increase again.


    Post a screenshot of your rules and we'll see why it's not working. If the wave is always displayed on screen, at what point are you seeing it go to 0? And have you tried putting Log Debugging Statements in before and after that point to see if they are showing up as expected?

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

Sign In or Register to comment.