How do I detect if a function param was passed or not?

  • Hi, I have a function that I would like to use some sensible defaults if nothing is overridden, but allow for passing in of values. So in the function I look at the values held by Function.Param(0..n) and see if they seem reasonable. If not, I use a default value, otherwise I assign the value passed in by the function to a local variable and use it.

    The problem is Function.Param() returns 0 if the script didn't pass any value, but 0 is a valid argument to pass in some cases. Is there any way to know whether the 0 returned by Function.Param() is something that was passed in or just the default 0? If the default of Function.Param() was null or NaN I could test for that and know that nothing was passed in.

    Another way to put the question is, "Is there a better way to define default Function parameters?"


  • Function.ParamCount tells you how many parameters were passed.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Thank you, blackhornet! That should do it.

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