how do you use PARAM_ARRAY

Forum for plugin, effect and behavior programmers. Please use the Help & Support forum for help using Construct.

Post » Wed Sep 09, 2009 2:16 pm

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;
Spriter Dev
B
87
S
21
G
12
Posts: 3,240
Reputation: 16,461

Post » Wed Sep 09, 2009 7:50 pm

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.
Scirra Founder
B
359
S
214
G
72
Posts: 22,946
Reputation: 178,478

Post » Wed Sep 09, 2009 7:58 pm

so is there's no way to have a variable number of parameters?
Spriter Dev
B
87
S
21
G
12
Posts: 3,240
Reputation: 16,461

Post » Wed Sep 09, 2009 11:31 pm

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).
Scirra Founder
B
359
S
214
G
72
Posts: 22,946
Reputation: 178,478

Post » Thu Sep 10, 2009 12:57 am

yes, but you can use a variable number of params in function expressions like this:
[code:16geysov]Function.MyFunction("somewhat", "interesting")[/code:16geysov]
as demonstrated by you :wink: in Hidden features #7: Function expressions .
I was actually wondering about arrays as parameters in expressions specifically
I don't really need them as params for actions or conditions
Spriter Dev
B
87
S
21
G
12
Posts: 3,240
Reputation: 16,461

Post » Thu Sep 10, 2009 10:00 pm

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.
Scirra Founder
B
359
S
214
G
72
Posts: 22,946
Reputation: 178,478

Post » Thu Sep 10, 2009 10:54 pm

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
Spriter Dev
B
87
S
21
G
12
Posts: 3,240
Reputation: 16,461

Post » Sat Sep 12, 2009 12:02 am

oh wow
just finally got a chance to try it
very simple
works perfect
thanks ash
construct rocks!
Spriter Dev
B
87
S
21
G
12
Posts: 3,240
Reputation: 16,461


Return to Construct engineering

Who is online

Users browsing this forum: No registered users and 2 guests