Array as a function parameter?

Get help using Construct 2

Post » Thu Feb 06, 2014 4:05 pm

Hello,

I found that in construct 2 Arrays are objects not types(like number, boolean etc).
I can't use function with Array parameter.
My current project has arrays or 5 element so I can use a function with 10 paramaters but for more complicated games It would be useful to use functions with arrays as parameter.

Thanks.
[size=200]1. Best Construct 2 course :HERE.10$!

2. 155 games source codes for sale on scrira store 12,86$each. PM me if interested to speed up the uploading process.
[/size
B
32
S
8
G
4
Posts: 148
Reputation: 3,713

Post » Thu Feb 06, 2014 4:50 pm

That's because an Array in C2 is a Plugin and not a Data Object like INT,STRING. The best you can do is pass the UID of the Array. I tend to name the array with a var and pass that. So you can work around it.
B
90
S
18
G
9
Posts: 2,455
Reputation: 15,013

Post » Thu Feb 06, 2014 4:54 pm

You can still reference arrays as you would reference objects. So depending on your need, you could "pass" an array to a function by using its UID.

edit : Here's an example where it creates 10 randomized arrays at start, then permits you to get the sum of one of them using a function and a UID parameter.Magistross2014-02-06 17:12:57
B
67
S
28
G
24
Posts: 970
Reputation: 18,675

Post » Fri Feb 07, 2014 6:49 am

That UID trick works!
Thanks you.
[size=200]1. Best Construct 2 course :HERE.10$!

2. 155 games source codes for sale on scrira store 12,86$each. PM me if interested to speed up the uploading process.
[/size
B
32
S
8
G
4
Posts: 148
Reputation: 3,713


Return to How do I....?

Who is online

Users browsing this forum: wizdigitech and 13 guests