Why is it not possible to call a function that returns a value with an action?

0 favourites
  • 5 posts
From the Asset Store
Game "Little Dino Adventure Returns" with complete Source-Code (Construct3 / .c3p) + HTML5 Exported.
  • Ashley

    Let's say I have a function "KillEnemy" which returns a value. Why can't I just call it if I don't care about the return value? Many programming languages allow this. In C3 I can only call it from an expression, so I need to do something like "set tempVar to Functions.KillEnemy", which is pretty inconvenient and makes the event sheet difficult to read.

    Tagged:

  • What if you don't make it a function that returns a value, but inside the function set a variable with output, that you can optionally use later if u want? Would that generate your desired result? It requires an extra variable but seems to behave how you want?

  • piranha305 Yeah, there are a few possible workarounds. I just don't understand why this limitation exists in the first place.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Currently the design is so that you don't clog up the function list for actions with loads of unwanted functions that are only used as expressions. Also part of the reason is because it's best to design things first in the most limited way and see if that is acceptable. It's extremely difficult to remove features, so once we add this, it can effectively never be removed again even if we decided for some reason it's much better to do it that way. However if later down the line we decide this really is important for some reason, it's much easier to add support for it than to take support for it away.

  • Currently the design is so that you don't clog up the function list for actions with loads of unwanted functions that are only used as expressions.

    Can you put all these functions under another group - "Functions that return value"? In a large project the list of functions can already be quite long, so adding another group will not do any harm.

    This change will make C3 functions a bit more flexible. Also, this is a commonly used functionality in other languages, so there will be no reason to remove it in the future.

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