Creating an event that doesnt spam at a specific value

xandramas

  • Posts: 411
how do i create an action to happen only once when a players hp hits a specific number.

Like 10 but only happen once when the hp is sitting on 10. I'm trying to create an explosion effect to happen once at 10 hp and turn off until hp hits 10 again after healed or damaged
Check my profile to test my games in development.
Asterite Saga: http://www.facebook.com/XGameLabs
Next Game in development.

Hectate

  • *
  • Posts: 4643
Use a boolean that starts false but gets set to true right after the event happens - it will happen once and then stop happening since the conditional that checks the boolean has changed.

For bonus points you could reset the boolean at a later time to allow it to happen again (so for instance if you wanted the explosion effect to happen again later, but no sooner than a minute after the last one just change it back again with a Do after 60 seconds block).
:
:
Patience is a Virtue,
But Haste is my Life.
Proud member of the League of Idiotic Stencylers; doing things in Stencyl that probably shouldn't be done.

xandramas

  • Posts: 411
that looks good but the problem that I am having is when the event is constantly triggered. Like when the player is sitting on 10 hp it'l keep triggering the event that happens at 10 hp instead of triggering only once.

What im trying to do is when a player's health hits or passes 10. To create an explosion effect. But if the player is on 10 hp for some reason I dont want it to keep creating that effect.
Check my profile to test my games in development.
Asterite Saga: http://www.facebook.com/XGameLabs
Next Game in development.

Tuo

  • *
  • Posts: 2469
Try this idea (Explosion is a boolean, default = false), an extension of hectate's idea:

If HP = 10
  If < Not < Explosion > >
     Set Explosion to True
     [Explosion coding]

If player collides with an actor
   Set Explosion to False
   [Change HP accordingly]
Don't look to me but rather to the One who is the reason for what I do. :)

If you need help, send me a PM. Even if I haven't been on in the forums in ages, I still receive those messages via email notifications. You can also reply to any of my forum posts, regardless of the age (especially if I created it), and I will likely reply.

If you want to see the programming behind certain types of games, feel free to check out my "Demo-" games on StencylForge (http://community.stencyl.com/index.php/topic,16160.0.html)

xandramas

  • Posts: 411
i'll try that out, thanks,
Check my profile to test my games in development.
Asterite Saga: http://www.facebook.com/XGameLabs
Next Game in development.

Unept

  • *
  • Posts: 351
Let me know how these suggestions work for you. I've been having a lot of trouble with this. I believe it's because I rely too much on the Always event, and less on the other events like boolean, comparison, etc. Still trying to figure it out.
Unicycle Hero: iOS  |  Level With Me: iOS/Android  |  Hue Ball: iOS/Android  |  Lava Bird: iOS/Android   |   Disposabot   |   Twitter

comport9

  • Posts: 51
The boolean "trick" works simply.

if hp==10 & boolean == False
   Do Stuff
   boolean = True

Then it'll only run once.