How does the function return a value? (Resolved)

0 favourites
  • 7 posts
From the Asset Store
Game "Little Dino Adventure Returns" with complete Source-Code (Construct3 / .c3p) + HTML5 Exported.
  • Hi, I have been using functions for a long time but today for the first time I need it to return a value. I haven't found where to look for this value, how do I get it after calling the function, please give me an example.

    In the screenshot is an example of a function that should return left or right.

    Tagged:

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • textvar=function.blockleftright(2,2,4)

    You assign a text variable to the function as above.

    yours

    winkr7

  • textvar=function.blockleftright(2,2,4)

    You assign a text variable to the function as above.

    yours

    winkr7

    I'm sorry, but I don't understand how you do it.

  • My mistake, I thought your function had three parameters (I saw the variables).

    in a new block declare a variable, lrValue as a string variable.

    set lrValue=function.blockLeftright

    lrValue will now contain the string "left" or "right".

    yours

    winkr7

  • My mistake, I thought your function had three parameters (I saw the variables).

    in a new block declare a variable, lrValue as a string variable.

    set lrValue=function.blockLeftright

    lrValue will now contain the string "left" or "right".

    yours

    winkr7

    I can't figure out how to do this in events or is this a java script you have?

    Please show a screenshot.

    It's times like this that I feel dumb.

  • To use return values, you will need to double click your function (as if you're about to rename your function) and you will have an option to set the "return type", either number or string.

    This will change how the function works, I.e. you can no longer call the function as an action anymore, and can only call the function as an expression (e.g. You can set a Text object's text to "function.block-left-right").

  • Now when you said about double-clicking I checked carefully and found that when creating a function you have to select the return type. Now everything is clear to me.

    Thanks Jase00!

    Thanks winkr7!

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