Metadata (via "Notes" field on Database)

● ARCHIVED · READ-ONLY
Started by Mellye 5 posts View original ↗
  1. The help file from RPG Maker MV tells us about a very useful feature, the ability to use the "Notes" field from the Database to setup custom metadata for any object:

    The Note field found in each item of the database can be used to define unique data used with each plugin.

    <name:data>In this way, data which has been written in a fixed format will be automatically developed inside a "meta" variable by standard scripts.
    In the case above, the following conditions will be met (objects will be treated as data).

    object.meta.name === 'data'
    I've been trying to make use of this, but to no success.

    For example, I added a <foo:bar> to a Enemy "Note".

    I have said enemy in a variable called "battler".

    console.log(battler.meta.foo);console.log(battler.meta);Both come up undefined.
    Code:
    console.log(battler)
    No sign of a property called "meta" anywhere.
    Code:
    if (battler.meta.foo === 'bar')
    Obviously throw an error because battler.meta.foo is undefined.
    I've taken a look at the DataManager.extractMetadata function, and it seems to be correct.

    So I'm not sure what I might be doing incorrectly. Any help is appreciated. Thanks!
  2. I don't think the engine does any of that automatically; it's outlining best practices for scripters.

    IIRC the note box is treated as one large regular expression, allowing it to be parsed by scripts which can extract the data they're looking for.
  3. I do not reallt understand JS and haven't look at the whole cod. But from what I've learned so far, meta is stored on the $dataSomething (i.e. $dataEnemies). It doesn't automatically passed to the Game_Something class (i.e. Game_Enemy). You have to setup that meta to Game_Enemy somewhere(usually on initialize method or setup method).

    If you're familiar with Ace notetagging, you might realize that it usually takes two step: filtering notes and save it to the instance variable of $data_something on your database, then pass that variable when initializing corresponding instance of Game_Something class.

    In MV engine, it will do the first step automatically. You still have to do the second step manually.

    CMIIW
  4. Oh, that makes sense; that's probably it.

    I'll take a closer look, thanks!

    Edit: Yup, just checked it, and that's exactly it.

    The raw data inside $dataEnemies has the meta property, I just needed to assign to the Game_Enemy object on initialization.

    Thanks again!
  5. Coolies!!!

    Good to know :)