How can I use script calls and write them into the notes and use note tags from plugins together?
I want to check a condition with "if (x = y) then notetag <itemColor:23> else <itemColor:1>
Is this possible?
Like, I did this for SumRnmDde's Summon Core to check if a position is taken or not:
if(PositionA != 1)
{
PositionA = 1
PA_Claws = 1
X: master._mainX - 120
Y: master._mainY
exit
}
else
if(PositionB != 1)
{
PositionB = 1
PB_Claws = 1
X: master._mainX
Y: master._mainY - 120
exit
}
if(PositionC != 1)
{
PositionC = 1
PC_Claws = 1
X: master._mainX - 120
Y: master._mainY - 120
exit
}
<End Summon>
PositionA, PositionB, PositionC are supposed to check if the position is availble or not.
PA_Claws means Claws is in position A.
PB_Claws means Claws is in position B.
PC_Claws means Claws is in position C.
I posted here because I want to learn how to do it.
Probably not in most cases I fear.
Most plugins will probably treat the note field as plain text and won't try to execute anything of it as javascript code by default.
Plus even if you update the note field during play, there is no guarantee plugins will reread it as note fields are usually expected to be constant.
The default plugins already provide an easy way to utilize notetags which other plugins can but don't have to use. At the start of the game each note field is checked for notetags and the results are stored separately for each item. Changes made to the note field afterwards are not reflected in the meta data.
For example, if your first weapon contains <sharpness:12> in its note field, plugins would be able to call $dataWeapons[1].meta["sharpness"] to find out that the weapon has a sharpness of "12" once the database is loaded.
Since most plugins expect this data to have a specific format, they probably won't try to execute "12" as javascript code unless you modify them specifically to do so.
You can find the function that extracts the meta data in 'rpg_managers.js' if you search for DataManager.extractMetadata . The function is called by DataManager.on_load which you find just above it and takes any database item as its argument.
I remember having seen multiple plugins that extend this function as it seems to be the perfect place to initialize custom values of your items.
that is done by the plugins.
by default, the notebox is just that, a sheet where you can put your notes. It has no function at all.
However, plugins can read what you place inside the notebox, and may react to notes placed there if they contain code to do so. that is what notetags are: texts for the plugin to search and handle.
Some plugins contain even code that eval's part of the text if they recognize their tags, but again that is specific to the plugin. Yanfly's Lunatic notetags work this way.
But it's the plugin that executes the code, not the engine - and each of those plugins executing their own notetags only and in their own context.
And how they do so also depends on the plugin.
Dang, so how can I do this? There's no way I suppose
you'll need to find or write a plugin that does what you want.
or (but this isn't always possible) you can analyse the plugin that reads those notetags and find out where it stores its data, and then use script calls in a regular event to change that.
As said, notetags have no function - that also means the plugin can't store or use that data directly. It reads the notetag and reacts to it, but it needs to store the true data somewhere to work with it.
That is the place where the data can be changed dynamically, but you need to be able to read the plugin code to find that place.