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
38,008
Reaction score
10,569
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,726
Reaction score
5,487
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,508
Reaction score
3,546
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

My mom showed up yesterday and I wanted to proudly show off my comic con web page. So of course, it no longer existed. I guess when the 4 day event was over they removed it.
Feeling like a creative Pattato this morning...
Calibrating the timing of dialogue is deffo my new least favorite thing.
I died aged 27 to cancer. Then I was reborn in a South-American state. I retained all memories and skill and had a goal from my previous life I needed to finish, but now I was just a 1-year-old girl capable of only smiling at others.

Dreams like this one make me glad I'm able to wake up from them at will.
Found a critical bug the other day with the time system that would have caused none of the NPCs to spawn. Since I use dev mode to test time-based stuff, I didn't catch this for way too long!

Forum statistics

Threads
129,979
Messages
1,206,686
Members
171,205
Latest member
CuriousMonkeyX
Top