Javascript-Powered Notes - No more messy note fields + Extra features possible!

ItsMeJohnC

Villager
Member
Joined
Jun 24, 2020
Messages
6
Reaction score
15
First Language
English
Primarily Uses
RMMV
NoteFieldsFromJS.js - v1.2

Introduction

If you're using Yanfly plugins or many other popular plugins that let you define complex behaviors through Note tags, you're probably aware that it's a bit of a mess, especially if you're embedding Javascript code in your note through Yanfly's Lunatic Mode and so on. Really this is an abuse of the note field - it was never designed for this much text, and the only way to manage it is to write everything in a separate text editor and copy and paste it into the field, which is annoying if you want to make changes.

This is meant to be used with plugins that allow complicated features to be coded up in note fields, and though a basic knowledge of Javascript will be useful for understanding how this works and coding your own special features, I've set things up so you technically can get by with no Javascript knowledge.


Features
This script provides two notetags to use:
<JSNote:functionName> (where functionName is the name of a Javascript function that returns your note text)
<JSNoteParams:param1,param2> (where param1,...paramN is a comma-separated list of parameters to pass to the function. Commas can be escaped with \, (backslash-comma).

Because now you are running Javascript to retrieve your note field, you can use all its power to add more dynamic features to your game. You could store some properties in a settings file and read it through Javascript, make certain behaviors change based on whether you start the game when the system clock says it's day or night, and so on. The sky's the limit if you're proficient in Javascript (or copy and pasting :wink: ). Of course, basically no knowledge is required to achieve the easiest feature of letting you edit and store complicated note fields.

Screenshots
I've referenced Yanfly's tutorial on Adapting Armor here as an example of how this cleans up complicated note fields.
image1.jpg



image2.jpg


How to Use
Put NoteFieldsFromJs.js into your plugin folder and enable it. If you have any plugins that modify how the database loads its data, place this plugin below those. It should be fully compatible. Once enabled, use the tags referenced above as needed.
You can organize your functions however you like, but in case you're hesitant due to little or no coding knowledge that's fine too - I've included a template called NoteFields.js, a template plugin that can serve as a place to put all your note field functions. Follow the examples inside that plugin to create your own functions easily.

Changelog
Code:
v1.2
===
- Re-include NoteFields.js template plugin
- Include more detailed documentation on how to use the NoteFields.js template plugin

v1.1
===
- Change notetag parsing logic so you can now reference info from values from the $data* objects like $dataArmors, etc.
- Compatability patch for Eli's  FindNameById (Database Organizer)
- Compatability patch for Yanfly's Doodads

v1.0
===
Initial release

Terms of Use: You are free to use this code in any project you like, including commercial projects. You may also modify or distribute this code with only the following restriction: Leave my name attached somewhere to the code, be it in the plugin author field or attribution added in the code itself.
 

Attachments

  • NoteFieldsFromJS-v1.2.zip
    2.8 KB · Views: 11
Last edited:

ItsMeJohnC

Villager
Member
Joined
Jun 24, 2020
Messages
6
Reaction score
15
First Language
English
Primarily Uses
RMMV
Updated with a new version! (v1.1)
  • Change notetag parsing logic so you can now reference info from values from the $data* objects like $dataArmors, etc.
  • Compatability patch for Eli's FindNameById (Database Organizer)
  • Compatability patch for Yanfly's Doodads
 
Last edited:

Eliaquim

Hakuen Studio
Veteran
Joined
May 22, 2018
Messages
3,071
Reaction score
2,352
First Language
Portuguese - Br
Primarily Uses
RMMZ
Oh my god, a compatibility patch for my plugin!!
haha! Pretty cool!
Actually I changed that plugin name to Eli FindNameById... But it still works the same.
Anyway, if you need anything just let me know ^^
 

ItsMeJohnC

Villager
Member
Joined
Jun 24, 2020
Messages
6
Reaction score
15
First Language
English
Primarily Uses
RMMV
Oh my god, a compatibility patch for my plugin!!
haha! Pretty cool!
Actually I changed that plugin name to Eli FindNameById... But it still works the same.
Anyway, if you need anything just let me know ^^

I'm using that plugin of yours in the game I'm making so I ended up making a patch for it
:smile:
 

Mojo907

Veteran
Veteran
Joined
May 21, 2013
Messages
191
Reaction score
43
First Language
English
Primarily Uses
RMMV
I feels like this is beyond awesome, and then I feels intimidates too!:guffaw:
 

ShadowDragon

Realist
Veteran
Joined
Oct 8, 2018
Messages
6,672
Reaction score
2,589
First Language
Dutch
Primarily Uses
RMMV
This seems very interesting, tiny notetag box to a HUGE insight rather than scrolling, scrolling
all
the









way







down to find the code to edit, very nice done :)

EDIT:
How exacly do you use this?
New JS file named: NoteFields (or any name) and inside
NoteFields.<functioname> = function () { .......} ?
 
Last edited:

ItsMeJohnC

Villager
Member
Joined
Jun 24, 2020
Messages
6
Reaction score
15
First Language
English
Primarily Uses
RMMV
How exacly do you use this?
New JS file named: NoteFields (or any name) and inside
NoteFields.<functioname> = function () { .......} ?

I just realized I accidentally removed the template plugin from the 1.1 version, sorry about that! That might be why it was confusing for you. I am uploading a 1.2 version with the template plugin and a slight clarification in the comments. In case you need more clarification, read on below.

When you add the <JSNote:functionName> tag, whatever you put for functionName it will call the function with that exact name and if it exists anywhere in the engine code base or across the code of all the loaded plugins, it will run that function. Of course, if it's missing you'll get an error. The only reason the NoteFields. portion is in front of the the function name is because I just arbitrarily decided to namespace the sample plugin like that. If you're not familiar enough with Javascript to know what that means, don't worry too much. Just use the template plugin like this (basically as you described):
Code:
NoteFields.<functionname> = function() {
    return `
Your
multiline
note
here`;
}

Just copy and pasting that as a template and changing the <functionname> and the text inside the quotes will allow you to create new notes. Then just reference the functionname you chose in the <JSNote:functionName> tag.

I hope that clears things up. :)
 

ShadowDragon

Realist
Veteran
Joined
Oct 8, 2018
Messages
6,672
Reaction score
2,589
First Language
Dutch
Primarily Uses
RMMV
that makes it clear, but I got 2 questions:

1) while this works in notefields (actor, skills, equip, etc), does this also works in tilesets Notetags and MapNotetag?

2) NoteFields.<functionName> = function (param1, param2), you have ${param1} ${param2}, are param
1 word or as long as you wish with "comma", to get to the 2nd param?

not sure what ${param1} means, still learning js, but it makes clear how to use it and template :)
 

ItsMeJohnC

Villager
Member
Joined
Jun 24, 2020
Messages
6
Reaction score
15
First Language
English
Primarily Uses
RMMV
1) while this works in notefields (actor, skills, equip, etc), does this also works in tilesets Notetags and MapNotetag?

2) NoteFields.<functionName> = function (param1, param2), you have ${param1} ${param2}, are param
1 word or as long as you wish with "comma", to get to the 2nd param?

not sure what ${param1} means, still learning js, but it makes clear how to use it and template :)

1) This should work for every note field, but if you find a situation where it doesn't, let me know and I'll see about adding compatibility when I have time.

2) In function (param1, param2), those are Javascript function parameters. You can name them whatever you want and have as many as you want, just separate them by commas. Look up function parameters and variable naming in Javascript for more info on what names are valid. When I reference them as ${param1} that's because I'm inserting them into the text I'm returning from the function. This ${} syntax means, "put the value that's in these curly brackets inside this string of text".

If you have a variable like: myVariable = 7...
return `<item id:myVariable>`; <- Don't do this, because you'll get literally "<item id:myVariable>". Instead:
return `<item id:${myVariable}>`; <- This gets "<item id:7>"
 

Latest Threads

Latest Posts

Latest Profile Posts

Interior of a bus, may do more vehicle interiors :kaoswt2:
1670089782219.png
I can hardly believe it is the third day of Christmas and I have yet to put up decorations! Spending my morning cooking breakfast and getting them up.
https://itch.io/s/83641/1-week-sale Do you want a Roguelike game like a turn-based Hades? Get Zodiac Hunters now while it's on sale!
2-0!!
1670083194124.png

Sorry to my fellow RPG maker users who are in the USA... We're kicking your butts! :)
(It's 2-0 at half time in the 8th finals of the WC Soccer. Loser goes home.)
At a store was a taste testing booth for Swiss cookies. After mentioning I'm Swiss, the guy gifted me a bunch of samples "in the spirit of an early St Nicholas". Made my day!

Forum statistics

Threads
127,010
Messages
1,183,162
Members
166,874
Latest member
albedo092
Top