Construct 3 suggestions & ideas

Suggest and vote on ideas for Construct 3! Please note this is only one aspect of planning. We do not guarantee any features here will be implemented, even if they are top-voted ideas. The aim is just to collect feedback. Remember to search for existing submissions before adding an idea, describe your ideas as comprehensively as possible, and vote for plausibleĀ ideas that are well thought out. Please seeĀ our full guidelines on suggesting features.

On Value Changed / On Variable Changed

This idea belongs to skyklown on discord but we were discussing how na Event condition that is triggered on value changed would be neat.

It would be good for both code cleanliness and optimization for games that have a lot of number managing.

A way to dispatch a signal for events to be ran when a specific variable has been affected. This could be useful for example in a scenario where you have 10 different events that can cause "Subtract Damage from HP" or "Add Heal to HP" events.

In the current case what you would do is to create a function, to and make sure to call that function each time in the code that variable has been affected. For example:

https://i.imgur.com/o7NessU.png

This can get a bit messy when more modular groups of events can affect the same variable. You make a note to remember that when you're making a change to HP variable, send this function. When you make a change to Kills variable, you send this function.

The alternative is to watch that variable on every tick and apply that to things like UI sometimes. Which is good for clean code but bad for optimization.

  • Rory S
  • Apr 3 2020
  • No status
  • Attach files
  • Rory S commented
    4 Apr 01:30pm

    @Ashley Fair enough! I didn't know that signals like that had any significant overhead to it. I could make a counter suggestion that some sort of send update boolean option on each of those Variable actions could be done, but that just makes things complicated and isn't really worth the trouble.

    I agree that it is the conventional way it's done in most engines, I was thinking of more of a simplicity feature, but then again if C3's goal is to be a good entry point or learning tool for new programmers then adding such conveniences could be counter to that anyway.

    Thanks for the response!

  • Admin
    Ashley Gullen commented
    4 Apr 11:39am

    This could have a major performance impact to all projects, even if they don't use the feature. It would mean every time the engine changes any kind of value, it has to look for 'On change' triggers and fire them. Even if this has a tiny overhead to look for triggers and not find any, setting variables is such a common and basic feature that it could significantly reduce performance of all games.

    Meanwhile the method you describe of using functions is how it works in pretty much all programming languages, none of which provide any generic "on variable changed" feature precisely because it would have far too much performance overhead. So I would suggest this is best solved with well-organised events and functions rather than risking a big slowdown in the engine for everyone.

  • +5