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

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?
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.
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.
RPGMZ_Tlmckez7Vq.png

nw_zAi7kkIOur.jpg

nw_9v45CX5gDU.jpg


So these are the screenshots, I just used the script on the Even Editor.
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
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"]

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
[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.

[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:
Double-post notice: @aztodio
Thank you so much, in my case 2 and 3 worked. I'll keep in mind to not double post in the future 🙂

Original thread: https://forums.rpgmakerweb.com/threads/call-a-plugin-by-script-while-one-of-the-argument-is-array.154533/