Has [Variable] Changed?

This forum is currently in read-only mode.
  • I know it's sorta late in 0.x's development for a feature request, but...

    It might clean up a lot of coding if there was an event to check if a sprite's variable has changed.

    That's it really.

    If someone could implement this it would be awesome!

  • at the beginning of each tick set a pv ChangeFlag to 0

    everytime you make a variable change, also change ChangeFlag to 1

    the condition pv ChangeFlag ==1

    would be what you're asking for

  • I mean I would need to check specifically, if [Health] or [Speed] or [xxx] or [yyy] has changed. Not just [any variable]

  • right

    you'd just have to make a second variable for each

    that's what would happen in the pv code to implement what you're saying, and it's just not in demand enough to be practical I think, especially at this point

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • There could be a built-in trigger - 'on variable changed' - but Construct would try to fire it every time you set the variable. I'm not sure because obviously it hasn't been measured, but this could end up being a significant performance drain on some projects. For example, if 5 fairly complex events fire every time you set a variable, that's a lot of overhead for a very simple action which is probably used a lot. Lucid's workarounds are probably a better idea, so we don't have to make everyone pay for a feature they might not use.

    My favourite trick is a second variable which is the 'old' value - for example, 'Health' and 'OldHealth'. Then you can do something like:

    + Every tick

    -> Set some value to 'Health' - 'OldHealth' (the "health difference")

    -> Set 'OldHealth' to 'Health'

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)