how do you use PARAM_ARRAY

This forum is currently in read-only mode.
  • i cant get the array param to work. is there a working example somewhere on the cvs? or could someone give a brief explanation of how it works?

    does it work with strings and numerical values?

    i tried several things to access the number of elements or the actual values, and it always comes back as 0;

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Don't use it, it isn't properly supported by the runtime. I think one or two plugins use it in a few corner cases, but I never got arrays working how I wanted.

  • so is there's no way to have a variable number of parameters?

  • No. The function object does this for calling functions with any parameters by using an action to add each parameter (remember a parameter can be of any type).

  • yes, but you can use a variable number of params in function expressions like this:

    Function.MyFunction("somewhat", "interesting")[/code:16geysov]
    as demonstrated by you   in [url=http://www.scirra.com/phpBB3/viewtopic.php?f=8&t=3068&p=23873&hilit=function+parameters#p23873]Hidden features #7: Function expressions[/url] .
    I was actually wondering about arrays as parameters in expressions specifically
    I don't really need them as params for actions or conditions
  • That's a special case designed for the function object. It sets the flag to enable undefined expressions. If the user types an expression name in the object which is not recognised, the runtime calls ExtObject::ReturnUndefinedExpression with whatever parameters were passed to the expression - so there can be any number, and any type. The one after the last parameter in the params array passed to every action, condition and expression always has a type of EXPTYPE_NULL, therefore the parameters can be dynamically counted and retrieved.

    I don't think this is supported by ordinary expressions I'm afraid.

  • so, does this mean it is possible, assuming i'm willing to check for each param_types, and for the null termination param?

    if so, where would i set the enable undefined expressions flag, and how do i check what the name of the expression they used is?

    my only alternative is to have them put in multiple params by making them input an array by just making a string of the array, like myfunction("this,that,34,21,theother") and then deconstructing the string into substrings checking for numerical values, and converting them.

    in other words, a big pain. if theres a way to get the undefined thing to work, regardless of how annoying it is, i'd prefer that over the string deconstruction thing

  • oh wow

    just finally got a chance to try it

    very simple

    works perfect

    thanks ash

    construct rocks!

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