I've tried different scripts but none of them worked for me. Suggestions?
MV Check event's comments
Javascript/Plugin SupportThere are a number of problems with that.
1) You're already inside an event, which would be what "this" is referring to - so what do you think this.event() means?
2) Events do not have a meta member, RPG Maker MV does not read event comments into metadata. It only does that with notetag fields.
If you want to do this, you need to write your own method to read the contents of an event as text, detect a comment, then extract the pertinent data from that. I know Yanfly's Common Event Menu does that, but it's a paid plugin, so that might be a little much just to use as a learning tool. I'm not familiar with something free that does it.
1) You're already inside an event, which would be what "this" is referring to - so what do you think this.event() means?
2) Events do not have a meta member, RPG Maker MV does not read event comments into metadata. It only does that with notetag fields.
If you want to do this, you need to write your own method to read the contents of an event as text, detect a comment, then extract the pertinent data from that. I know Yanfly's Common Event Menu does that, but it's a paid plugin, so that might be a little much just to use as a learning tool. I'm not familiar with something free that does it.
Script commands are evaluated in the context of their interpreter (
Comments are a bit different. There is no core script method to fetch all Comment commands or scan them for a specific tag. However, you can do that manually, e.g.
Game_Interpreter), so you can use:this.character(0)= "This Event"this.character(0).event().meta= "notetag data for This Event"
event() method goes from the Game_Event instance to the corresponding $dataMap entry.Comments are a bit different. There is no core script method to fetch all Comment commands or scan them for a specific tag. However, you can do that manually, e.g.
@caethyril not going to pretend, I don't quite understand how to use this.
After that I've tried adding two script calls for the last remaining line:
$gameActors.actor(1).setName(ev.tag)
$gameVariables.setValue(1, ev.tag)
and check values in an message window "\V[1]\N[1]", both had values of zero.
Am I missing something?
P.S. I know how to check event's notes, but I need comments too since I thought it would be easier than dissecting the note's name into separate values, etc since they're not flexible enough.
After that I've tried adding two script calls for the last remaining line:
$gameActors.actor(1).setName(ev.tag)
$gameVariables.setValue(1, ev.tag)
and check values in an message window "\V[1]\N[1]", both had values of zero.
Am I missing something?
P.S. I know how to check event's notes, but I need comments too since I thought it would be easier than dissecting the note's name into separate values, etc since they're not flexible enough.
Sorry, I misremembered without the editor open. I don't think I've ever used that.
The example in the post I quoted is designed to match something in the form
<tag: X>, where X is an integer. For something like <tag: text>, try this instead:
JavaScript:
var RX = /<name:\s*([^>]+)>/i; // match <name: text>
var ev = this.character(0);
var res = ev.list().filter(function(command) {
return [108, 408].contains(command.code); // comments only
}).map(function(comment) {
return comment.parameters[0]; // get comment text
}).reduce(function(a, c) {
var match = RX.exec(c);
return a.concat(match ? [match[1]] : []) // push matches to array
}, []);
console.table(res); // test! (F8 during test to show console)
$gameVariables.setValue(1, res[0]); // store first match in game variable 1
<name: text> tag per comment line (comments can have multiple lines, that's what code 408 is for). There might be a better approach, but this seems to work for me! 😤More technical details on regular expressions can be found here~
Regular expressions - JavaScript | MDN
Regular expressions are patterns used to match character combinations in strings. In JavaScript, regular expressions are also objects. These patterns are used with the exec() and test() methods of RegExp, and with the match(), matchAll(), replace(), replaceAll(), search(), and split() methods of...
Imagine an event's note box is a mess like this:
BigBadBeetroot<enemy><vegetable><age: 341.2><can fly><alien>The event's
meta property, created automatically by the core scripts, should still be nice and tidy:{
age: "341.2",
alien: true,
"can fly": true,
enemy: true,
vegetable: true
}Comment tags are only really necessary if you want to store different tags for each event page.
I ended up using other methods, but I won't close the thread in case someone finds an answer.
Thread closed
(at OP's request)
(at OP's request)
Original thread: https://forums.rpgmakerweb.com/threads/check-events-comments.137370/