Need a confirmation on the way functions return values

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

    I just face a behavior that seems different from programming languages.

    The Set return value action.

    If I do not create Else branches, the different conditions are evaluated one by one.

    My question : does the Set return value action just set the value that will be returned at the end of the function ? If so, is there a way to get out of the function like a "classic" return ?

    Tagged:

  • instead of using a function, you can use variables that take on the value according to the condition, for the function it would have to have a defined function, it works as if it were a really previously defined function, in fact in the current scheme it performs the actions of simultaneously

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • It just sets the return value and does not exit the function. There is no way to exit the function other than running to the end of it. So what you did with else’s is one solution to do that.

    You can consider the event sheet as its own unique programming language. The object picking is the most unique part. Take away that and it’s similar to most programming languages with if/else/loops/functions. It does have its differences though, such as no way to immediately exit out of a function or loop like return or break.

    I don’t have a good explanation for why that is. It was inspired by the click team products event sheets, but made more hybrid to better resemble structured programming. At this point we are in comparability mode. They can add new features but changing existing ones will break a bunch of things. But event sheets as a whole would benefit from tweaks and redesign in parts.

  • Thanks for your quick replies !

    Snakegbr I don't get exactly what you mean, setting variables from the result of the conditions and use it after in another condition ? What would do another function in this case ? (if you could write it in pseudo-algorithm you're welcome but it's ok if you don't ;))

    R0J0hound Thanks for the confirmation and for giving me a quick view of the event system. I used Construct 2 some time ago, I came back to C3 to give it a chance again, or inversly, C3 could give me a chance to achieve my projects in another way :D

    And you're right, the picking part is very specific. The code you see here is for a mahjong game, and I had to discover the Pick top instance action which is very useful in that kind of game !

    I know the developer (or game designer) must stick to the engine if he wants to get the maximum of it, like any other engine. I still find C3 very user-friendly and very quick to setup things, but I have to learn again from it !

    I recently made a remake of Apple Season by Orisinal but haven't pushed it to the forum or Scirra Arcade yet.

    Thanks again for the code review.

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