difficulty evaluating a game attribute after value changed

goonergooner Lancaster, PAMember Posts: 135

1) actor "sign" sets the value of game.currentExit (using random 1,4) when game.currentExit = 0 (working)
2) actor "sign" displays value of game.currentExit when game.currentExit > 0 (working)
3) actor "soldier" visits the current Exit which sets game.currentExit = 0 (working)
4) step 1 should happen again and give game.currentExit a new random value since game.currentExit = 0 (not working)

It doesn't seem to re-evaluate game.currentExit. I have this type of issue often, sorry if I've asked a similar question in the past. Should this be in a timer, mod numeric expression, or should it be expected to re-evaluate since the value is changing back and forth from 0 to (1-4) and back to 0? I'm stumped, any advice or suggestions appreciated. Thanks.

Comments

  • RabidParrotRabidParrot Formally RabidParrot. Member Posts: 956

    Can you upload a screenshot?

  • goonergooner Lancaster, PAMember Posts: 135

    unfortunately not at the moment, not at my home computer. in the meantime, should the actor have re-evaluated on it's own and repeated step 1 or was I wrong in that assumption?

  • RabidParrotRabidParrot Formally RabidParrot. Member Posts: 956

    Maybe,

    when currentExit = 0, Add a timer that says after .03 seconds change game.currentExit to (random 1,4)

    Without a screenshot I can only give you vague answers. It's much easier If we see the code.

  • goonergooner Lancaster, PAMember Posts: 135

    @RabidParrot said:
    Maybe,

    when currentExit = 0, Add a timer that says after .03 seconds change game.currentExit to (random 1,4)

    Without a screenshot I can only give you vague answers. It's much easier If we see the code.

    thank you! I will try that when I get home.

    also was wondering if having the same actor change the game attribute value and also display it when it changes could cause issues.

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    edited October 2015

    @ellison said:
    also was wondering if having the same actor change the game attribute value and also display it when it changes could cause issues.

    No, this has nothing to do with it.

    What's likely happening is that you're assuming a rule will trigger whenever its condition is true. But this is not how rules work in GameSalad. A rule will only trigger when its condition changes from false to true. As an example, this rule:

    When game.number > 0

    Will trigger when game.number changes from 0 to 5. But when game.number changes from 5 to 6, it won't trigger again. Game.number would have to be 0 (or less than 0) and then change to a number greater than 0 for the rule to trigger again.

    Edit: looking at how you described your rules, it should in fact trigger again. So perhaps your rules aren't that simple or aren't set up correctly? Can you post a screen shot?

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

  • grishlockgrishlock Member, PRO Posts: 32

    The rule triggering only after being reset was a hard lesson for me.

  • goonergooner Lancaster, PAMember Posts: 135

    @RabidParrot said:
    Maybe,

    when currentExit = 0, Add a timer that says after .03 seconds change game.currentExit to (random 1,4)

    Without a screenshot I can only give you vague answers. It's much easier If we see the code.

    adding the after .03 timer worked.

    now is this a case of forcing bad code/logic (i've been known to :wink: ) to work or is this an accepted workaround to prevent a race condition?

    PS - really appreciate all the feedback, as always it keeps me moving forward and motivated ... and learning more about gamesalad of course.

Sign In or Register to comment.