Actor Notes Field

Hi,

What is the script for checking if a specific string is in the notes field of the Actor section of the database for an actor with a known ID that isn't in the party?

Thanks,
JavaScript:
const actorId = 5;
const searchString = "yourString";

const actorData = $dataActors[actorId];

if (actorData && actorData.note.includes(searchString)) {
    console.log(`Found : "${searchString}" for ID ${actorId}.`);
} else {
    console.log(`Not found : "${searchString}" for ID ${actorId}.`);
}

Should work, but did not test
To clarify that, if actorId = 5, would $dataActors[5].note.includes(searchString), have the same effect in the script line of the conditional branch field?
Thank you. That did in fact work.

It turns out the reason it didn't appear to be working was because I had another script that was running into a different error later on, and I thought the error from the second script was caused by the first.
To clarify that, if actorId = 5, would $dataActors[5].note.includes(searchString), have the same effect in the script line of the conditional branch field?
Yes, as you noticed it has the same effect.

The reason I put it in a condition is to prevent errors
Say actor ID 5 does not exist, a direct call will likely crash the game, where as my condition example will simply say "not found"
To clarify that, if actorId = 5, would $dataActors[5].note.includes(searchString), have the same effect in the script line of the conditional branch field?
Yes, the variables are extraneous. Also, the typical use of the note field in-game is to create notetags: surrounding a word with angled brackets.

These are automatically parsed when the game boots into the meta property of the actor entry. So putting
<hero>
would cause this check to be true: $dataActors[5].meta.hero
and putting
<weight:175>
would cause this to have the value of "175": $dataActors[5].meta.weight
Yes, as you noticed it has the same effect.

The reason I put it in a condition is to prevent errors
Say actor ID 5 does not exist, a direct call will likely crash the game, where as my condition example will simply say "not found"
That is a good thing for me to keep in mind, although at this point in the development process, a straight up crash isn't a bad way of pointing out that there's a problem with this aspect of the game.


Yes, the variables are extraneous. Also, the typical use of the note field in-game is to create notetags: surrounding a word with angled brackets.

These are automatically parsed when the game boots into the meta property of the actor entry. So putting
<hero>
would cause this check to be true: $dataActors[5].meta.hero
and putting
<weight:175>
would cause this to have the value of "175": $dataActors[5].meta.weight
Thank you for this clarification. Just so I know for the future, what's the difference between $dataActors and $gameActors? I tried using the latter as per the Script Calls list (i.e. $gameActors.actor(actorId).meta.notetag, and it kept on throwing an error when I tried to call the meta property.
$dataActors ($data-anything) is your entries in the database. Anything you typed into a field in a database entry (including the notes) is stored there.

$gameActors are objects created during gameplay and written to the save file so that you can change parts of an actor during the game. That's how you can rename an actor, add or remove skills, change its class, etc.
Thanks! That clears a lot up.

Original thread: https://forums.rpgmakerweb.com/threads/actor-notes-field.172945/