MZ Script for use with ButtonPicture default plugin (MZ)

Does anyone know if you can use a script in a Loop that will provide the necessary input for the default MZ plugin ButtonPicture?

When you use the ButtonPicture plugin, you designate a Picture Id and a Common Event Id each time you use the Plugin Event Command Option.

I have to set 99 ButtonPicture commands in an Event. And I wanted to make a Loop that uses Variables for the Picture Id and the Common Event Id. Then I just need to increment each Variable by 1 in the Loop to use the next Picture Id and Common Event Id.

Currently, my Picture Ids are 301 - 399 and the Event Ids are 401 - 499.

I looked inside the ButtonPicture .js file and I kind of sort of see what it is doing. But I don't know how I would construct a Script Event Command to use in this sort of Loop.

I would think it would be possible, but I don't know enough to figure it out.

So instead of 99 separate Plugin Event Commands that each set a Picture Id and Common Event Id, you would just set 1 Variable at 301 and 1 Variable at 401, have a Loop, a script that uses something like $game.Variables.value(#) for both the Picture Id and the Common Event Id, increment each of those Variables by 1, and then if the Loop goes through 99 times you break the Loop.

I hope this makes sense and I have explained it clearly. And thanks for any help you can provide or for letting me know that this isn't possible with the ButtonPicture plugin.

Here is an excerpt of the ButtonPicture plugin .js file.

Spoiler: ButtonPicture .js
ButtonPicture.png
I think this format might be what you are looking for:
Code:
PluginManager.callCommand(
  interpreter,
  pluginName,
  command,
  args
);

I am not sure if you need to involve any game variables here so if you can clarify, that'd be great.

You could try this out and see if it works. I'll assume there are only two argument properties in this plugin since I am not familiar with it (modify as needed - if 'this' doesnt work, use '$gameMap._interpreter' without quotes):

Edit of edit: string in args not required for numbers:
JavaScript:
for (let i = 1; i < 100; i++) {
    PluginManager.callCommand(
        this, 'ButtonPicture', 'set',
        {pictureId: 300 + i,
         commonEventId: 400 + i});
};
for (let i = 1; i < 100; i++) { PluginManager.callCommand( this, 'ButtonPicture', 'set', {pictureId: 300 + i, commonEventId: 400 + i}; ); };
Wow! You just helped me reduce 99 Event Commands down to this small script! I had already added them all, so I wished I had thought to ask this earlier, but this lets me make the Event more streamlined and it taught me something new!

I did have to modify the script just a bit. I initially got an error. But I just moved the closing parenthesis ")" to appear immediately after the closing curly bracket "}" and it works like a charm!


for (let i = 1; i < 100; i++) {

PluginManager.callCommand(

this, 'ButtonPicture', 'set',

{pictureId: 300 + i, commonEventId: 400 + i});

};

And the awesome thing is that now that I see the script, I can actually understand what it is doing!

Thank you so much for your help! You have come to my aid once again and I greatly appreciate it!

EDIT: I saw the EDIT above, but it appears to work without the string format. But I will test that as well. Thanks again!
Wow! You just helped me reduce 99 Event Commands down to this small script! I had already added them all, so I wished I had thought to ask this earlier, but this lets me make the Event more streamlined and it taught me something new!

I did have to modify the script just a bit. I initially got an error. But I just moved the closing parenthesis ")" to appear immediately after the closing curly bracket "}" and it works like a charm!


for (let i = 1; i < 100; i++) {

PluginManager.callCommand(

this, 'ButtonPicture', 'set',

{pictureId: 300 + i, commonEventId: 400 + i});

};

And the awesome thing is that now that I see the script, I can actually understand what it is doing!

Thank you so much for your help! You have come to my aid once again and I greatly appreciate it!

EDIT: I saw the EDIT above, but it appears to work without the string format. But I will test that as well. Thanks again!
Thanks! Glad it worked out. I wasn't sure since the example used strings, but that is good to know.

I don't have MZ so I couldn't test it. lol leave it to a rogue semi-colon to ruin code haha.

Now looking at it, I think it is using JSON Parse or something on those arguments so it would work either way. I'll return the edit back to normal for reference.
@bass2yang AWESOME! This is why you are already in my credits list for specific mention. Your help with scripts and plugins has significantly contributed to my Sudoku game.

I will leave this open for a bit to see if anyone else wants to clarify or add anything and then I will ask that the thread be closed.

This is very cool!
@bass2yang AWESOME! This is why you are already in my credits list for specific mention. Your help with scripts and plugins has significantly contributed to my Sudoku game.

I will leave this open for a bit to see if anyone else wants to clarify or add anything and then I will ask that the thread be closed.

This is very cool!
Thank you - you are very kind and thoughtful.

I am humbled to be mentioned in your project. I learn a lot from all the devs on here (and definitely still learning - still new at this) and it's always great to see people working through their games.

And, I get a good laugh at myself whenever I miss things that the debug picks up on even after looking at it several times before testing haha. Time used for what... a parenthesis missing? Misplaced semi-colon?... yup. Every. Time.

Original thread: https://forums.rpgmakerweb.com/threads/script-for-use-with-buttonpicture-default-plugin-mz.169143/