How do I call functions with parameters?

0 favourites
  • 12 posts
From the Asset Store
Basic clone of a 80's arcade game called Gyruss that was quite fun to play!
  • Hi

    I found a nice Match 3 tutorial that uses Functions. It was written for C2 but I figured it should be applicable to C3. Aaaand I got stuck when it came to functions... I have to admit I haven't used functions in C3 much so I have no idea how to get this done.

    If anyone would be willing, can you show me how this would look in C3:

    Huge thank you!

    Tagged:

  • It's the same, except the parameters now look like variables so you use them instead of function.param(x).

  • It can't be the same because you can't use functions expressions for a function that you call. You either set it up so you can call it or you set it up so you can use it with expression. As far as I can tell...

    The problem in the posted pictures is function "CheckMatchesX" - in event 19 it is called as an action and then in event 25 it's used in condition as an expression for X coordinate of object Block.

  • 19 you do in the same way, call as an action > functions. 25 you replace function.param(0)with the parameter that now appears as a kind of selectable variable in the list.

  • Thank you but I don't think you are correct. According to the manual:

    By default, functions have a return type of None, meaning they don't return any value. This also means they are used as actions. However if you set a return type of Number, String or Any, the function returns a value. This also means it is used as an expression instead, so it won't appear as an action.

    You can't use the same function in actions and as an expression. That is why is asked for help :/

  • Yeah, I also think this is an unnecessary limitation, I made a post about it:

    construct.net/en/forum/construct-3/general-discussion-7/why-not-possible-call-150368

  • Hello Spela !

    My name is Eleanor and I'm pretty good at using construct 3,

    If you want to do that, make your function have a return value and create a local variable,

    and then in your action so "add to variable: functions.function(...args)"

    and you will get the result that you want.

    Best wishes,

    Eleanor

  • Hello again Spela,

    I forgot to mention, you could also create a javascript action block and do runtime.callFunction("functionname",...args)

    Best wishes,

    Eleanor

  • The functions you posted look like they can be set to return type None though so shouldn't be a problem?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Hello Spela !

    My name is Eleanor and I'm pretty good at using construct 3,

    If you want to do that, make your function have a return value and create a local variable,

    and then in your action so "add to variable: functions.function(...args)"

    and you will get the result that you want.

    Best wishes,

    Eleanor

    OK, local variables it is, thank you! I'm afraid javascript is a bit beyond me :)

    Unfortunately, to use a function expression as a part of a condition, it can't be set to type None. It was possible in C2, but not anymore.

  • eleanorjmorel It worked, thank you again :)

    I have a couple unrelated C3 questions, is there a way I could contact you? Perhaps on discord? Thanks!

  • Greetings Spela

    You can join my discord server if you want, I have a construct 3 help channel

    Here'S the link discord.strawberrypunch.com

    Best wishes,

    Eleanor

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