Array as Parameters

Milena

The woman of many questions
Veteran
Joined
Jan 26, 2014
Messages
1,281
Reaction score
106
First Language
Irish
Primarily Uses
N/A
In the plugin manager, we can create a function via script via Numbers and Parameters so we can change the value of a var inside the plugin manager. But that somehow only works for single number. What code should I put so I can change array values of one variable from the plugin manager?
 

Ramiro

Now with an army of Mecha-Ralphs!
Veteran
Joined
Aug 5, 2015
Messages
858
Reaction score
364
First Language
Spanish
You'll have to do it manually there is no way to do that automatically:

Things you must considerer: you'll have to "reserve" a character as "a separator of values", in this examples we'll use ',' because it looks simple:

var params = PluginManager.params("MyPlugin");var myArray = params["My Array Param"].split(','); // change , for your separatorThen myArray will have well, an array.

In your plugin manager you'll use a comman separated list:

Looking like this:

----------------------------------------

| My Array Param | 1, 2, 3, 4, 5 |

----------------------------------------

You may put on the parameter's help as something like "a comma separated list of numbers representing something"
 

Iavra

Veteran
Veteran
Joined
Apr 9, 2015
Messages
1,797
Reaction score
863
First Language
German
Primarily Uses
If i understand correctly, you want array parameters for your plugin? Parameters are always String objects, so if you want to get an array, define a separator (a comma, for example) and parse them like this:

Code:
var params = PluginManager.parameters('My Plugin'); // Or different solution (see my signature)var myArray = params['My Array'].split(/\s*,\s*/).filter(function(value) { return !!value; });
The "filter" part is to discard empty elements.
 

Milena

The woman of many questions
Veteran
Joined
Jan 26, 2014
Messages
1,281
Reaction score
106
First Language
Irish
Primarily Uses
N/A
Yes, thank you Ramiro and Iavra, problem solved! This really helps. <3
 

DarknessFalls

Rpg Maker Jesus - JS Dev.
Veteran
Joined
Jun 7, 2013
Messages
1,393
Reaction score
210
First Language
English
you can do something like: functionName(array) where array is something like var array = [ ... ]
 

Iavra

Veteran
Veteran
Joined
Apr 9, 2015
Messages
1,797
Reaction score
863
First Language
German
Primarily Uses
Not really, since this has 2 drawbacks:


1) You only pass 1 parameter, which is an array.


2) "this" inside the called function is set to the object it belongs to. When using call() or apply() you can specify "this".
 

DarknessFalls

Rpg Maker Jesus - JS Dev.
Veteran
Joined
Jun 7, 2013
Messages
1,393
Reaction score
210
First Language
English
2) "this" inside the called function is set to the object it belongs to.
consider the following:

Code:
var self = this;something.map(function(some){ self.fucntionName() })
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

Couple hours of work. Might use in my game as a secret find or something. Not sure. Fancy though no? :D
Holy stink, where have I been? Well, I started my temporary job this week. So less time to spend on game design... :(
Cartoonier cloud cover that better fits the art style, as well as (slightly) improved blending/fading... fading clouds when there are larger patterns is still somewhat abrupt for some reason.
Do you Find Tilesetting or Looking for Tilesets/Plugins more fun? Personally I like making my tileset for my Game (Cretaceous Park TM) xD
How many parameters is 'too many'??

Forum statistics

Threads
105,867
Messages
1,017,062
Members
137,575
Latest member
akekaphol101
Top