MV Create Arbitrary Notetags for Database Enteries

Hello! 👋

I'm hoping someone would be able to help me with a bit of an odd plugin request. What I'm hoping to do is be able to create arbitrary notetags for database objects, such as Enemies, Items, Weapons, Armors, etc. These notetags don't do anything at all, but would be able to return the value (number or text) and save that value to a variable.

To give an example of what I'd use this for, I'm working on a card game. All of the creature cards will be set up as Enemies in the database. I'd like to be able to add notetags to the enemies such as the following.

<Description1: A small bird with leafy feathers.>
<Description2: Tap - Deal 2 damage.>
<Element: Nature>
<Cost: 20>

Then, I would retrieve these values by setting a variable to their value, so I can use it in message windows and other events. This could be something along the lines of using this in a Control Variables event:

$dataItems[$gameVariables.value(1275)].Description1

I hope I explained this in a way that makes sense, please let me know if you have any questions.

Thank you! 🙂
Code:
/*: @target MZ
 *
 * @command readNotetag
 * @text Read Notetag
 *
 * @arg variableId
 * @text Variable
 * @type variable
 * @desc Variable that holds the Index of the Enemy
 *
 * @arg notetag
 * @text Notetag
 *
 * @arg variableToStoreId
 * @text Variable to store info
 * @type variable
 *
 */

PluginManager.registerCommand('ReadEnemyNotetags', 'readNotetag', args => {
  const enemyIndex = $gameVariables.value(Number(args.variableId));
  const enemy = $dataEnemies[enemyIndex];
 
  if (enemy && enemy.meta) {
    $gameVariables.setValue(
      Number(args.variableToStoreId),
      enemy.meta[args.notetag] || 0
    );
  }
})

Please name this file "ReadEnemyNotetags.js" otherwise it won't work.
Please name this file "ReadEnemyNotetags.js" otherwise it won't work.
this might not work as its MV, yours is in MZ 😀
Thank you so much for helping me out! I tested out the plugin in MV, and make sure to save it with the correct filename, but I am running into this error on launch.

Also, just to be sure, would this be the correct plugin command to use to get the Element notetag from the enemy ID stored in variable 22, and save that value to variable 21?

readNotetag 22 Element 21
this might not work as its MV, yours is in MZ 😀
Ah right, it says MV in OP's box.

For MV, a direct call is maybe easier than a whole plugin:

Code:
$gameVariables.setValue(
  2,
  $dataEnemies[$gameVariables.value(1)].meta["Description1"],
)
Reads Notetag Description1 of enemy with the ID of variable's 1 value, and puts it into Variable 2.
Ah right, it says MV in OP's box.

For MV, a direct call is maybe easier than a whole plugin:

Code:
$gameVariables.setValue(
  2,
  $dataEnemies[$gameVariables.value(1)].meta["Description1"],
)

Reads Notetag Description1 of enemy with the ID of variable's 1 value, and puts it into Variable 2.

Oh, that would work perfect! I just tried it out, and it works like a charm! Thank you so much! 🙏
not sure about the last comma on it, but here is a mini function
that you could save for easy access.

JavaScript:
function grabEnemyMeta(varId, index, metatag) {
    $gameVariables.setValue(varId, $dataEnemies[$gameVariables.value(index)].meta[metatag])
};

variable ID to store the info,
index variable to grab the ID of the enemy
metatag is the one your want grab

you can copy and past for $dataItems, $dataWeapons, $dataArmor, $dataSkills etc
and do the same thing for easy access, less typo's 🙂
just as an added FYI:
the meta function is also described in MV's Help file under plugins
it's a rather short description, but it is there.
I made it a bit easier to grab any database entries from the following:
enemies
skills
items
weapons
armors
actors
classes

I added the plugin, theoretically, it should work, but smaller to use a single line
of code, and added a new param for extracting those.

@Vis_Mage you might want to test if it works, so it would be great if it does 🙂
bit easier than the above scriptcall (or each their own).

you can use the same scriptcall, same variable, index if needed, just change
the to the entry of database to grab info from 🙂
@ShadowDragon Thank you so much for organizing it all into a plugin for me! I tested it out, and it works like a charm! Having it all together in one short script call is really handy!
Thanks again! 🙏
Thank you so much for organizing it all into a plugin for me! I tested it out, and it works like a charm! Having it all together in one short script call is really handy!
Thanks again! 🙏
your welcome, it's easier than all types of scriptcall, I found this the easiest
way for you.

thank Aerosys too for the previous scriptcall 🙂 forgot to add his name for it,
but this can be quite useful to draw metatags from anything for any particular
reason if you ask me.

good luck with your project 🙂

Original thread: https://forums.rpgmakerweb.com/threads/create-arbitrary-notetags-for-database-enteries.176006/