MZ [SOLVED] Populate a command arg dynamically

Hello, I want to populate a command arg dynamically on the plugin startup.

JavaScript:
/*:
 * @target MZ
 * @author Raidez
 *
 * @command selectMotor
 *
 * @arg which
 * @type select
 * @option XP
 * @option VX
 * @option VX Ace
 * @option MV
 */

(() => {
    const PLUGIN_NAME = "test";

    PluginManager.registerCommand(PLUGIN_NAME, "selectMotor", function (args) {
        console.log(args);
    });

})();

Spoiler: screenshot
1743321669985.png
So you want to automatically list all options available in the editor for that arg, like this?
  • ["XP", "VX", "VX Ace", "MV"]
I don't think there is a way to reference header information directly from the code. It may be possible to get a reference to the current script element, then match against @arg which? I think the easiest solution is to just copy the available options into the code.

Alternatively you could standardise all @type select parameter values, e.g.
  1. Preface the options with a number, then parse the arg as a number:
    @type select @option 0 - XP @option 1 - VX @option 2 - VX Ace @option 3 - MV

  2. Use the @value directive of @type select, then parse those values instead:
    @type select @option XP @value 0 @option VX @value 1
(In-game, in a plugin command, args is just an object indexed by arg name, e.g.{ which: "MV" }.)
No, you don't get it.

I want to add element in my option with code :
JavaScript:
// not actual code, just an exemple
args.which = ["option1", "options2", "options3"];

And these new options will be displayed inside RPGMZ.
I think, it's impossible but I still ask.
Oh, OK. No, I don't think the editor supports any alternative syntax for @option. I think the only way would be to modify the header section of the file, manually or using code. 😴

@type combo would make it easier for users to enter unlisted values. But any preset values would still need to be given in the header using @option as usual.

Original thread: https://forums.rpgmakerweb.com/threads/solved-populate-a-command-arg-dynamically.176633/