MZ How do you set up a multiline Notetag?

After a bit of asking (probably a few too many) questions on the internet, I finally managed to write a plugin which actually does what it should!
Amazing, isn't it? Yeah, I still don't believe it myself.
Anyway, after this torture i have to take the next step and expand the functionality of the plugin a bit. I would now like to use a function for this that is often found in the Visustella plugins, but somehow doesn't really want to work for me: Multi-line note tags. Specifically, these are note tags who save their value not inside the bracket of the notetag, but rather are split in 2 notetags to build a block of values with the one below having a additional / to mark the end of this block. A example of how that can look would be:

<Drops>
Item 5: 20%
Item Potion: 30%
Weapon 27: 45%
Weapon Blade of Reckoning: 55%
Armor 72: 72%
Armor Flame Shield: 90%
</Drops>

now i have tried to use this technique myself, but unfortunately something seems to be misinterpreting something. it seems like it interprets the 2 brackets as 2 notetags with a boolean instead as 1 big "block notetag". now i found a way to simplify that for my plugin because it just wasnt required at the moment, but now i wanna make the next step and i need to find out why the plugin does misinterpret my notetag.
The built-in notetag parsing only handles <name: value>, so you will need to parse this manually from the database record's note property.

This has to be done after the database has loaded, so you could patch the Scene_Boot.prototype.onDatabaseLoaded method.
Hi there!

There are several ways of doing that, but I rather prefere using a much easy and simple approach. Let's say you have this on a weapon note tag:

JavaScript:
<Drops:
Item 5: 20%
Item Potion: 30%
Weapon 27: 45%
Weapon Blade of Reckoning: 55%
Armor 72: 72%
Armor Flame Shield: 90%
>

Now, on code, you can reference it like this:

$dataWeapons[id].meta.Drops

If you want to check each line, you can put each line inside an array:

const myArray = $dataWeapons[id].meta.Drops.split("\n")

The index 0 of the array will be empty on the example above. But these are details that you can format inside your code: Put every line in an object, or formatting the array removing the empty indexes, etc...

BUT if you want to make exactly like Visustella, you have to ask them since they have obfuscated code.
But with REGEX I believe you will find your way through it.
To expand on what caethyril said, this will involve regular expressions (RegEx) so brush up on that.
What Eli described is how I do it in my plugins. It does mean users can't use > in the tag values, but otherwise it's much easier to set up.
What Eli described is how I do it in my plugins. It does mean users can't use > in the tag values, but otherwise it's much easier to set up.
I prefer regex just so that I don't have a tag that isn't closed on the line it starts, that gives me anxiety. XD
The built-in notetag parsing only handles <name: value>, so you will need to parse this manually from the database record's note property.

This has to be done after the database has loaded, so you could patch the Scene_Boot.prototype.onDatabaseLoaded method.
The thing is, my plugin is supposed to work with the visustella engine anyway, so it wouldnt be a huge issue anyway.
Hi there!

There are several ways of doing that, but I rather prefere using a much easy and simple approach. Let's say you have this on a weapon note tag:

JavaScript:
<Drops:
Item 5: 20%
Item Potion: 30%
Weapon 27: 45%
Weapon Blade of Reckoning: 55%
Armor 72: 72%
Armor Flame Shield: 90%
>

Now, on code, you can reference it like this:

$dataWeapons[id].meta.Drops

If you want to check each line, you can put each line inside an array:

const myArray = $dataWeapons[id].meta.Drops.split("\n")

The index 0 of the array will be empty on the example above. But these are details that you can format inside your code: Put every line in an object, or formatting the array removing the empty indexes, etc...

BUT if you want to make exactly like Visustella, you have to ask them since they have obfuscated code.
But with REGEX I believe you will find your way through it.
however, if it is that easy, then i will just try out that first, as it seems like it will in practice require very little change in the code if i wanna change-over to the other way.
To expand on what caethyril said, this will involve regular expressions (RegEx) so brush up on that.
actually, i looked into a tutorial about RegEx, and it seems not pretty hard, the only thing that irritated me in the practice was that i needed to use / / instead of "" when using meta.notetag.match()
The thing is, my plugin is supposed to work with the visustella engine anyway, so it wouldnt be a huge issue anyway.

however, if it is that easy, then i will just try out that first, as it seems like it will in practice require very little change in the code if i wanna change-over to the other way.

actually, i looked into a tutorial about RegEx, and it seems not pretty hard, the only thing that irritated me in the practice was that i needed to use / / instead of "" when using meta.notetag.match()
Yeah, that's just industry standard for denoting a regex pattern, not much anyone can do about that.

Original thread: https://forums.rpgmakerweb.com/threads/how-do-you-set-up-a-multiline-notetag.153858/