Notetag questions & snippet!? Is there one?

Hi everyone 😉 I'm completely new to regex and thought I'm struggling big time with this problem xD
I was wondering if there is a javascript snippet for RMMV for reading notetags.

for example:

<notetag:22> I think I can use meta for this... for example enemy.meta.notetag.

what about this:

<notetag>
lots of stuff here I mean really lots of stuff here xD
</notetag>

how can I read this kind of notetags?!

also where is the correct place to load such data?! for example I am to add a new tag to the enemies, a profile much like
with actors. Can I create a variable.. $enemyData[x]._profile = profileText;

and read it from the DataBase notetag: <profile>blahh</profile> if so where should this handling be done? every new game?
every gameload? where is the place? 

I know these are a lot of questions. Thank you in advance!
You use regex for this:

var match = /<notetag>(.*?)<\/notetag>/.exec($dataActors[1].note);This will test whether actor #1 contains the given notetag. If not, "match" will be null, otherwise it will be an array containing the whole matched string at index 0 (irrelevant for this) and the matched captured string (everything between <notetag>...</notetag>) at index 1.
For your second question, there are 2 ways to do this:

- Lazy load this information. Have some function like "function getData()", which checks if the data has already been loaded and, if not, loads it.

- Load everything at startup. Since you usually have to wait, until all data has been loaded, you'll need to extend a function like DataManager.isDatabaseLoaded, which returns true once all data is available.

You should read this information every game, otherwise you'll need to store information in the savefile, which not only will bloat the files, but also will make your plugin not plug-and-play, which could be bad for game developers testing around.
Meta tags are easy as hell to read.

<metanotetag: 500>$dataActors[1].meta.metanotetagDone 🙂
Meta tags are easy as hell to read.

<metanotetag: 500>$dataActors[1].meta.metanotetagDone 🙂
We don't have to check if it has spaces? I mean, it can store the variable of metanotetag as 500 even with adding spaces in it?
I don't use regex, my friend built a tool that he released here on the forums that parses tags. 😀
We don't have to check if it has spaces? I mean, it can store the variable of metanotetag as 500 even with adding spaces in it?
JS liberally converts types where possible, so even though the meta tag i saved as a string, if your using it as a number, it will auto convert to a number and thus, the spaces will be removed.

If its an actual string your reading, might want to check and remove any initial spaces 🙂

Also, there is many many note parsing functions available. For example, the mv commons plugin has one built in, which you would struggle to find better than. 🙂
if your using it as a number, it will auto convert to a number and thus, the spaces will be removed.
Beware unintended sideeffects of this, though ^^


In my Self Variables plugin i forgot to explicitly convert to a number and 6 + 2 ended up being 62 ^^
You use regex for this:

var match = /<notetag>(.*?)<\/notetag>/.exec($dataActors[1].note);This will test whether actor #1 contains the given notetag. If not, "match" will be null, otherwise it will be an array containing the whole matched string at index 0 (irrelevant for this) and the matched captured string (everything between <notetag>...</notetag>) at index 1.
For your second question, there are 2 ways to do this:

- Lazy load this information. Have some function like "function getData()", which checks if the data has already been loaded and, if not, loads it.

- Load everything at startup. Since you usually have to wait, until all data has been loaded, you'll need to extend a function like DataManager.isDatabaseLoaded, which returns true once all data is available.

You should read this information every game, otherwise you'll need to store information in the savefile, which not only will bloat the files, but also will make your plugin not plug-and-play, which could be bad for game developers testing around.
Thank you very much for such fast answer 🙂 this is great! 

Original thread: https://forums.rpgmakerweb.com/threads/notetag-questions-snippet-is-there-one.51303/