How can I retrieve param from function using scripting

0 favourites
  • 3 posts
From the Asset Store
With this template you will learn how to use the GooglePlay Games native plugin
  • So I have a function called func() in my event sheet.

    Somewhere else, I'm calling this line via scripting :

    runtime.callFunction("func", param);

    The issue now is, sometimes the param I'm sending is either a string or an integer

    How can I retrieve the parameter in func() and check its typeOf?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Functions in Construct's event sheets only support string, number or boolean types. There is not an "any" parameter type so you cannot sometimes pass a string and sometimes pass a number to the same parameter. You can work around this by having a string parameter, a number parameter, and a boolean parameter indicating which parameter should be used.

  • Hello Ashley, this seems to do partially what I want currently, except that in a huge loop, I have to specify everytime which param needs to be a string or number.

    Furthermore, if I now want to send lots of parameters (e.g JSON values), this gets messy. (Now having lots of similar functions/loop/checks in the long run... oh no)

    In my humble opinion, having "any" could greatly simplify the use of function parameters and avoid lots of redundant variables since we can just check the "is value type" for the received variable. Thank you.

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