RMMZ Call a plugin by script while one of the Argument is array?

aztodio

Veteran
Veteran
Joined
Mar 21, 2020
Messages
37
Reaction score
35
First Language
English
Primarily Uses
RMMZ
So I tried with FilterControllerMZ and Visustella's plugin, everytime the Argument is an array, I don't know how to make it work.
Like this one:
PluginManager.callCommand(this, 'FilterControllerMZ', 'createFilter', { filterId: 33, filterType: 'crosshatch', filterTarget: 'SpecificPicture', targetIds: 12, positionReferenceTargetId: '', });

@arg targetIds * @desc when choosed "SpecificChar/Picture", specify the event/picture(s) id here. (multiple OK) * @type string[] * @default []
targetIds type is string[], I tried to use 12, "12", '12', [12], ["12"], ['12'] all of them didn't work. Please tell me what did I do wrong?
 
Last edited:

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
37,930
Reaction score
10,512
First Language
German
Primarily Uses
RMMV
Both '12' and "12" should register as strings.
if you already tested that and it didn't work, then the problem is likely the context and we need to see the entire event/script to start guessing where the error is.
 

ATT_Turan

Forewarner of the Black Wind
Veteran
Joined
Jul 2, 2014
Messages
7,546
Reaction score
5,311
First Language
English
Primarily Uses
RMMV
Your question is very confusing. Why aren't you using the proper interface provided to you in MZ to call the plugin command? That would format it correctly for you.

As far as a string goes, both "12" and '12' are strings. But it looks like that code you typed has an extra comma at the end, after the value for positionReferenceTargetId.
 

aztodio

Veteran
Veteran
Joined
Mar 21, 2020
Messages
37
Reaction score
35
First Language
English
Primarily Uses
RMMZ
RPGMZ_Tlmckez7Vq.png
nw_zAi7kkIOur.jpg
nw_9v45CX5gDU.jpg

So these are the screenshots, I just used the script on the Even Editor.
 

aztodio

Veteran
Veteran
Joined
Mar 21, 2020
Messages
37
Reaction score
35
First Language
English
Primarily Uses
RMMZ
Plus, if I change SpecificPicture to FullScreen, then it works. I assume because the script would skip the value of targetIds in that case. But the filter effect affects the whole screen...
nw_S3hek7x7Ch.jpg
 

aztodio

Veteran
Veteran
Joined
Mar 21, 2020
Messages
37
Reaction score
35
First Language
English
Primarily Uses
RMMZ
When I searched the forum, I believe this one had the same problem as mine, they couldn't call VisuMZ_4_PictureCmnEvts through javascript, maybe because PictureIDs is array?

@arg PictureIDs:arraynum * @text Picture ID(s) * @type number[] * @min 1 * @max 100 * @desc Select which Picture ID(s) to change. * @default ["1"]

 

GmOcean

Veteran
Veteran
Joined
Nov 29, 2020
Messages
195
Reaction score
159
First Language
English
Primarily Uses
RMMZ
Have you tried wrapping the entire array in a string literal? `[12]` or `["12"]` ?
They may be using eval() to compute the information passed, but I'm no expert.
Have you also tried literally giving it an array, by assigning those values to an array variable fist? Like idArray = ["12"];
and
targetIds: idArray,
?

Edit: use Caethryil's suggestions, much better than my chicken scratch xD
 
Last edited:

caethyril

^_^
Global Mod
Joined
Feb 21, 2018
Messages
4,485
Reaction score
3,514
First Language
EN
Primarily Uses
RMMZ
[Edit: ninja'd.]

Plugin command arguments should all be JSON-encoded strings, regardless of type. Try one of these:
  1. targetIds: "[12]"
  2. targetIds: "[\"12\"]"
  3. targetIds: JSON.stringify(["12"])
Option 1 returns an array of type number[], so it might not work depending on how the plugin parses its inputs. Options 2 and 3 should be equivalent and they mimic the default Plugin Command behaviour.

Also, a note for future:

@aztodio, please avoid double posting, as it is against the forum rules. You can use the "Edit" function on your posts to add additional information you've forgotten or respond to multiple people. You can review our forum rules here. Thank you.

 

aztodio

Veteran
Veteran
Joined
Mar 21, 2020
Messages
37
Reaction score
35
First Language
English
Primarily Uses
RMMZ
[Edit: ninja'd.]

Plugin command arguments should all be JSON-encoded strings, regardless of type. Try one of these:
  1. targetIds: "[12]"
  2. targetIds: "[\"12\"]"
  3. targetIds: JSON.stringify(["12"])
Option 1 returns an array of type number[], so it might not work depending on how the plugin parses its inputs. Options 2 and 3 should be equivalent and they mimic the default Plugin Command behaviour.

Also, a note for future:
[dpost]@aztodio[/dpost]
Thank you so much, in my case 2 and 3 worked. I'll keep in mind to not double post in the future :)
 

Latest Threads

Latest Posts

Latest Profile Posts

Came back cuz of the sale. Got MZ. The System 2 advanced settings for UI are so frustrating, and I see we still hate pixel fonts. Marvelous.
Did another YouTube short. This one has like 1k views (or maybe 380? Analytics is being weird). Getting them zoomer views, yo!
Done edit sprite Raven witch char for main party.
niagarabekasi.jpg

Dirty waterfall in satelite city bekasi.
credit: Hiddeone for knight, LadyBaskerville XP to MV, whtdragon for reindeer, witch nude body by RayaneFLX
I'm really sorry I haven't done any streams. I actually just got home from the hospital after a week and a half.
I'm not dead - I promise :stickytongue:

Anyway, some pokemon inspired art (dont ask me which one tho xD)
reali.png

Forum statistics

Threads
129,718
Messages
1,204,620
Members
170,793
Latest member
duozhengqian321
Top