Plugin to manipulate an array

For developers using the Construct 2 Javascript SDK

Post » Sat Dec 31, 2016 4:53 pm

I'm trying to write a plugin which receives three parameters: width, height and a reference to an array.
I have an action which, based on width and height, should manipulate the array. However, I can't figure out how to write to the array.
I tried
Code: Select all
Acts.prototype.Generate = function (width, height, array)
{
   array.set(2, 3, 44);
};

which doesn't work, as 'array' doesn't expose the array methods.
What I am missing?
B
21
S
5
Posts: 23
Reputation: 1,207

Post » Mon Jan 02, 2017 12:14 am

@Tiredentes Unfortunately, you cant pass an array as a parameter as C2 does not support passing objects such as arrays, vectors etc... . For now you can only pass ints, floats, strings, instances or keyboard virtual keys.
Banned User
B
17
S
7
G
23
Posts: 388
Reputation: 13,994

Post » Mon Jan 02, 2017 11:38 am

Here is a plugin to reset official array by a csv string.
B
108
S
26
G
271
Posts: 4,471
Reputation: 151,777

Post » Thu Jan 12, 2017 10:50 pm

@X3M Thank you, I see. I ended up forking the official array plugin and adding the needed functionality with a new method. Neither elegant nor clean, but it does the job.
@rexrainbow I tried to understand in the code how you link to the array, but it seems to be beyond my JS skills... :-( Thank you anyway, I hop to find some time to study the source code of your plugins, I guess I can learn a lot.
B
21
S
5
Posts: 23
Reputation: 1,207


Return to Javascript SDK

Who is online

Users browsing this forum: No registered users and 0 guests