Addition Problem

CrestwoodCrestwood Member Posts: 80
edited May 2012 in Working with GS (Mac)
I have an actor called Heart2, and an attribute called Health(index) default 500.

if attribute game.health=500 + touch is pressed
destroy actor

if attribute game.health=475 + touch is pressed
change att game.health to game.health+25 <----this works fine, and health goes to 500
destroy actor

if attribute game.health <=450 + touch is pressed
change att game.health to game.health+50 <---this works if it as 450, it will add up to 500

but, if it is at 425 or lower, it still adds it up to 500. Instead of 425 +50 =475.

I do have an actor Heart1 that does +25 hp and it works fine since the rule is very simple, meaning if it is 475 or below, add +25.

Am I missing something here?

Best Answer

  • jckmcgrawjckmcgraw Posts: 647
    Accepted Answer
    @Crestwood

    I believe that you have some conflicting rules...

    Rule: when game.health ≤ 425 + touch is pressed, change game.health to game.health + 50

    Rule: when game.health = 475 + touch is pressed, change game.health to game.health + 25.

    When the first rule triggers, it instantly changes game.health to 475. While touch is still pressed, (I think) that it is triggering the 2nd rule I mentioned. Therefor, when game.health ≤ 425 + touch is pressed, you may as well have it be when game.health ≤ 425 + touch is pressed, change attribute game.health to 500.

    You will need to change something about those rules...

    I hope this helps,
    Jack McGraw

Answers

  • CrestwoodCrestwood Member Posts: 80
    Ahhh. I was thinking in absolutes if it met the requirements.

    You are 100% correct. I added an attribute to fix this easily.

    Thanks Jack!!
  • jckmcgrawjckmcgraw Member Posts: 647
    @crestwood

    Glad I could help!
Sign In or Register to comment.