Crestfall9

Procrastinator
Member
Joined
Mar 5, 2018
Messages
13
Reaction score
6
First Language
Indonesian
Primarily Uses
RMMV
I wanna start making notetags in my plugins. I've been looking at other plugins but I never got a single clue on how to make notetags. How do I do it?


Also offtopic: I've been looking at MV's documentation in https://kinoar.github.io/rmmv-doc-web/modules/rpg.animation.html. There's a reference on rpg_library.js but I never found it. Can anyone explain?
 

Poryg

Dark Lord of the Castle of Javascreeps
Veteran
Joined
Mar 23, 2017
Messages
4,147
Reaction score
10,708
First Language
Czech
Primarily Uses
RMMV
The easiest way to figure it out is to create a couple of notetags in the editor (for example you add a <test: true> notetag to the first weapon.
Then launch the game, open the dev console and type in $dataWeapons
then explore.
I can't type in more, because I still don't have my computer and because I don't know about your js knowledge. However, notetags are saved in property _meta, which is an object containing all notetags.
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
33,675
Reaction score
8,490
First Language
German
Primarily Uses
RMMV
start by going to the helpfile and search for the description of the meta-function there.
that is a finished function for this - it has several limitations (which is why a lot of plugins write their own), but it will give you a start
 

TheoAllen

Self-proclaimed jack of all trades
Veteran
Joined
Mar 16, 2012
Messages
6,315
Reaction score
7,845
First Language
Indonesian
Primarily Uses
RMVXA
Start by learning regular expression, and how to read them. You can try to google them and follow tutorial how to use regex.
For example: https://www.w3schools.com/jsref/jsref_obj_regexp.asp

Then find the way how to access note from database, idk how to do it in MV. But it should be easier than learning regex itself
 

Poryg

Dark Lord of the Castle of Javascreeps
Veteran
Joined
Mar 23, 2017
Messages
4,147
Reaction score
10,708
First Language
Czech
Primarily Uses
RMMV
@TheoAllen Actually, I don't use regex in my notetags, since it's a string and if I need to convert it to a number, I can do it with just one line of code. But I usually don't use notetag processing functions, I just take it from the meta property when I need it. The only case when this is not usable is the example of multiline notetags, such as Yanfly's lunatic mode.
 

TheoAllen

Self-proclaimed jack of all trades
Veteran
Joined
Mar 16, 2012
Messages
6,315
Reaction score
7,845
First Language
Indonesian
Primarily Uses
RMVXA
@Poryg interesting. Will that works for more complex plugins for public use?
 

LTN Games

Indie Studio
Veteran
Joined
Jun 25, 2015
Messages
708
Reaction score
638
First Language
English
Primarily Uses
RMMV
As Pyorg mentioned, fetching the meta is the easiest way but if you need more control like multiline note-tags then proceed with a quick explanation below.

I do multiline note-tags by using FeniXTools and the tools do it in 2 steps.

First you need a function to filter/search the string you give it and return matches via regex.

PHP:
// Taken from https://fenixenginemv.gitlab.io/fenix-tools/Utils_filterText.js.html
function filterText (text, regex, action) {
  const result = []
  let match
  const re = regex
  while (match = re.exec(text)) { // eslint-disable-line no-cond-assign
    if (action(match)) {
      result.push(match)
    }
  }
  return result
}

then the next step is to give this above function the correct information

PHP:
// Taken from https://fenixenginemv.gitlab.io/fenix-tools/Utils_getMultilineTag.js.html
function getMultiLineTag (text, tag) {
  const result = []
  const re = /<([^<>]+)>([\s\S]*?)<(\/[^<>]+)>/g
  const matches = filterText(text, re, (match) => match[1].toLowerCase() === tag.toLowerCase())
  matches.forEach(group => {
    result.push(group[2].trim())
  })
  return result
}

the above code uses a regex pattern for finding the tags <tag> </tag> and then returns everything in between them. Mind you this will only return an array of strings, each element in the array being a separate match, how you parse that string is up to you, I left this open to the developer because they may want to manipulate things their own way.

How would you use the above function? Well based on a notetag like this

<myTag>
opt1: 1,
opt2: 2
<myTag>

PHP:
const myNotes = getMultiLineTag($dataWeapons[1].note, 'myTag') // => ['opt1: value, opt2: value']

Something quick to convert one of those strings to an object would be rather simple but this is based on the string using a comma to determine the end of a pair.

PHP:
function toObject (string) {
  const obj = {}
  const properties = string.split(',')
  properties.forEach((property) => {
    const tup = property.split(':')
    obj[tup[0]] = tup[1].trim()
  })
  return obj
}

And to convert would be as easy as something like this this

PHP:
const myNotes = getMultiLineTag($dataWeapons[1].note, 'myTag')

toObject(myNotes[0]) // => {opt1: 1, opt2: 2}

Hope this helps in some way, it should get you started and you could probably make your own version of fetching notetags that is suitable for you. Cheers!

P.S FeniXTools does it as simple as this, without the need to copy and paste the code above, but you need to know how to use a bundler or FeniXCLI which is in early stages at the moment.

PHP:
import { getMultiLineTag } from 'fenix-tools'

const myNotes = getMultiLineTag($dataWeapons[1].note, 'myTag') // => ['opt1: value, opt2: value']
 

Poryg

Dark Lord of the Castle of Javascreeps
Veteran
Joined
Mar 23, 2017
Messages
4,147
Reaction score
10,708
First Language
Czech
Primarily Uses
RMMV
@TheoAllen It will. For example Yanfly uses the raw text to process notetags, which is saved in a different property, and _meta doesn't get touched at all as far as I know.

The only thing that may be required in cases of more complicated notetags, such as <actorSkills: 1,2,3>, you need a processor function. But you can essentially just overwrite the _meta's properties and then use them when needed.
 

Frogboy

I'm not weak to fire
Veteran
Joined
Apr 19, 2016
Messages
1,834
Reaction score
2,343
First Language
English
Primarily Uses
RMMZ
Why would you bother using note tags any longer? Everyone is on 1.5 or higher now and that comes with the improved plugin parameters that require a lot less work to process.
 

Crestfall9

Procrastinator
Member
Joined
Mar 5, 2018
Messages
13
Reaction score
6
First Language
Indonesian
Primarily Uses
RMMV
Man I can write a novel sized essay on just how confused I am with all of this. Autodidact maybe is not a good way. It's very intriguing reading all those pages though. Really shows just how shallow I am in all of this.

Bundling the JS is what interests me. The concept of cramming lots of scripts into one is just so hard to comprehend.

FeniX uses rollup to bundle, but is it possible to use webpack instead?
 

LTN Games

Indie Studio
Veteran
Joined
Jun 25, 2015
Messages
708
Reaction score
638
First Language
English
Primarily Uses
RMMV
@Frogboy it's easier for the developer I'd assume, I mean when I'm editing things for my items or weapons I want to do it all in the database directly beside the weapon or item. If I had to switch to the plugin manager and then close it to cross reference information in the database I'd get annoyed very quickly.

@Crestfall9 FeniXCLI does not currently use Webpack but If you know how to setup Webpack in your project then by all means use it with FeniXTools as it's a seperate library that can use any bundler. However, the final output is a lot messier and not as easy to read when using WebPack. With Rollup the final output is literally all the code wrapped in an iife and it looks good. To me Webpack is just a whole lot for such a small job, I could understand if you had a bunch of utilities and CSS etc to bundle but this is just JavaScript and it's just one plugin.
 

Crestfall9

Procrastinator
Member
Joined
Mar 5, 2018
Messages
13
Reaction score
6
First Language
Indonesian
Primarily Uses
RMMV
Going back and forth between plugin manager can be a bit annoying so I wanna use notetags.
And I might use Rollup instead.
 

Frogboy

I'm not weak to fire
Veteran
Joined
Apr 19, 2016
Messages
1,834
Reaction score
2,343
First Language
English
Primarily Uses
RMMZ
@LTN Games
I'd argue that you're going to be more annoyed having to constantly cross reference the documentation and figuring out what you typed in wrong. You do make a valid point, however.

I'd never be able to pull off the things I do without that 1.5 plugin format, though.
 

Poryg

Dark Lord of the Castle of Javascreeps
Veteran
Joined
Mar 23, 2017
Messages
4,147
Reaction score
10,708
First Language
Czech
Primarily Uses
RMMV
@Frogboy I'd rather scroll through 500 enemies in database to find the one where I need to edit the notetag than see that enemy 469 has wrongly set up parameter, open the list and scroll through the enemies while still trying to remember it's line 469. But I guess it is a matter of preference here. I can do just fine even without the 1.5.1 plugin format, since all parameters are essentially strings in the end.
 

Frogboy

I'm not weak to fire
Veteran
Joined
Apr 19, 2016
Messages
1,834
Reaction score
2,343
First Language
English
Primarily Uses
RMMZ
Fair enough.

I can do just fine even without the 1.5.1 plugin format, since all parameters are essentially strings in the end.

Ah, but they don't have to be. :cool:
 

Aesica

undefined
Veteran
Joined
May 12, 2018
Messages
1,821
Reaction score
1,725
First Language
English
Primarily Uses
RMMV
Why would you bother using note tags any longer? Everyone is on 1.5 or higher now and that comes with the improved plugin parameters that require a lot less work to process.
Some things make a lot more sense on note tags than buried in plugin parameters. Specifically, things associated with a given actor, item, monster: stealable items, libra descriptions, skills learnable for a given class via job points, etc. Detaching them from their associated templates only makes things unnecessarily complex.
 

Traverse

Veteran
Veteran
Joined
Jul 3, 2014
Messages
193
Reaction score
125
First Language
English
Primarily Uses
There's a reference on rpg_library.js but I never found it. Can anyone explain?

Not me, I have no idea where any of that site's information on "Internals" comes from.

There is no actual file called rpg_library.js or rpg_mv.js open for editing. Most of the data described in those pages is located within the .json files in your project's "/data" folder (or in the ".rpgsave" files for config and save file info stuff). Perhaps it's referring to some temporary internal placeholder file created by the MV editor to keep track of the data before permanently writing it to the .json files. Although if that's the case, I have no idea how they got access to it.

Man I can write a novel sized essay on just how confused I am with all of this. Autodidact maybe is not a good way. It's very intriguing reading all those pages though. Really shows just how shallow I am in all of this.

Bundling the JS is what interests me. The concept of cramming lots of scripts into one is just so hard to comprehend.

I like how this has suddenly gone from "how do you parse notetags" to bundling code just because of one guy flogging a set of developer tools meant for coding optimization. Which only incidentally happens to use notetags as an example of the benefits.

I'd say if you don't yet know ANY method of how to implement notetags, it is way too soon to be looking at optimizing the process and you won't be getting much use, if any, out of FeniX Tools/Engine.

But in response to the original question:
I wanna start making notetags in my plugins. I've been looking at other plugins but I never got a single clue on how to make notetags. How do I do it?

First, to clarify something, a "notetag" typically refers to a certain text string placed in the notes box (hence "note" tag) of one the engine's database pages (whether an actor or item or weapon or armor, etc). This string usually looks like "<this>", the contents being some form of text inside and/or between multiple sets of <> brackets.

You don't -make- them in your plugins, you make them in the note boxes of the database pages and code your plugins to read them. If the data is directly wired into the plugin's parameters, they're not notetags anymore, they're just plugin settings. There's only 2 real steps to make a plugin "use" a notetag: A ) Read the tag/text string and B ) Extract ("parse") the relevant data from it which the rest of your plugin needs to use. The point of having < and > brackets is purely to mark where the tag is meant to begin and end for the purposes of reading it (as opposed to, you know, actual notes in the notebox that are just meant to be notes).

Back in the VX/Ace days, it didn't have to be <> brackets. It could have been {} or [] or whatever the coder wanted, but I guess since {} and [] brackets are used for referring to arrays and hashes in coding, people just found it less confusing to use <> brackets. It didn't really matter since the tag itself was just a text string, people just made their own string-processing code (via string matching, regular expressions/"regexps", capture groups, etc.) to find the tags, break them down and extract the data.

Fast forward to MV. The DataManager in rpg_managers.js now comes with a built-in, pre-coded function that automatically reads and extracts any text enclosed in <> brackets found in the note boxes and saves it for easy reading. The note data itself is stored in the .json files, but as you might already know, those files are loaded into $dataXXXX global variables by the DataManager when the game loads. At this time, it runs its shiny new "extractMetadata" function, scans the note data and saves any <X:Y> text strings it finds into the variable's "meta" property with X being a variable and Y (or anything after the : colon) being the value (Y, or everything past the colon, is saved as one whole string, spaces and all). If there is no colon, the value of X is simply set to "true".

This is the basic "notetag" functionality of MV. You can see this all in DataManager in rpg_managers.js. As the others say, if you want to use a single tag to hold multiple values (whether over multiple lines or separated by commas or whatever) you need to write your own text parsing code to break up the tag's value and extract the info like in the pre-MV era. And if you want to use something other than <> to mark your tags, you will need to code your own note box reading function too, since it won't be read by "extractMetadata" and hence won't be saved in $dataXXXX.meta for easy access.

I hope this helps.
 
Last edited:

LTN Games

Indie Studio
Veteran
Joined
Jun 25, 2015
Messages
708
Reaction score
638
First Language
English
Primarily Uses
RMMV
Just to make things clear I'm not "flogging" I was nice enough to come here and extract code from my set of tools to show exactly how to extract noteags without actually needing to use the developer tools or a bundler. I explained what does what, even though the code speaks for itself. A little respect for my time, my explanation and my code would of been a bit nicer than saying I'm flogging for a community that I've given my all for, including support, these free set of tools and the 14 plugins I made all free of charge.
His choice to use a bundler or my tools is up to him, and considering how easy it makes things I don't blame him, that's kind of the point for making the tools, to help with common tasks, for newbies or advanced developers, it does not matter who uses it.

Anyways, for those coming here to figure out how to extract and parse notetags, specifically multilinee noetags, since I seem to be the only one here who actually provided working code and a small explanation. Feel free to use the above code to do that and no you won't need the actual developer tools or a bundler to get it working. I hope I helped with my quick explanation and example code if anyone needs further support feel free to ask me.
 

Latest Threads

Latest Posts

Latest Profile Posts

Too bad the Boss Battle Build Bout isn't also for VXAce.
I might not participate in the Boss Battle contest after all... I have more important things to do, like Wishful Wanda. And of course the Dark Deception spinoff I plan to pitch, Demon Slayer.
Changed my avatar, goodbye Alan Sugar, hello George Carlin (one of my favorite human beings ever)
If you still don't subscribe our Polish channel please consider it :)
1.png
Who wants to see my review of the worst star wars movie? This movie has all the excitement of being on Jury Duty of the most boring case ever about trade negotiations.

Forum statistics

Threads
115,173
Messages
1,087,833
Members
149,727
Latest member
wizard54
Top