Can someone explain this?
For example, in my event, I did a comment:
<sound: 4>
<picture: 6>
Now, I am told that we can use .contains or .match. WhenI do this:
if (this.page().list.parameters[0].match(/<sound:\s*(\d+)?>/im)) {
var sound = this.page().list.parameters[0].match(/<sound:\s*(\d+)?>/im)[1];
this.eventSoundNumber = Number(sound);
}
It won't actually read the value and place it to my new variable eventSoundNumber. In my understanding, it should be able to since it is matching the expression. When I use contains it just do the same. Is there a way to check the <sound: x> tag while keeping <picture: x> or vice versa?
Also, meta is anywhere there is a note. $dataItems, $dataWeapons, and so on.
Meta works but be careful.
Also concerning match, match doesn't return anything, only whether there is a match or not against the regular expression.
If you want to get data from using a regular expression.
You want to use the .exec method.
After that you need to take your lastIndex property, and set it to 0 after evaluation. It will get the digit you want from sound if the expression matches.
Actually, I just realized that meta is saved per event, not per page. So if you want to grab and apply data per page, you will need to use a method similar to the one in the first post. Here is one I just whipped up ... should work alright.
this.page().list.forEach(function(data) {
if (data.code == 108 || data.code == 408) {
var tmpMatch = data.parameters[0].match(/<(sound|picture):\s*(\d+)?>/i);
if (tmpMatch) {
switch (tmpMatch[1]) {
case 'sound':
this.eventSoundNumber = Number(tmpMatch[2]);
break;
case 'picture':
this.eventPictureNumber = Number(tmpMatch[2]);
break;
}
}
}
}, this);
That will search through the entire page to search for matches.
I would suggest using more unique identifiers, though. 'sound' and 'picture' are pretty generic, and might be used by another plugin developer on accident.
Ah. I just assumed she wanted it in event comments as that's the way the first post is worded.
Events also have notes, so you can use .meta without having to make something read them. Unfortunately though, they're all on a single line in a very small-to-read/edit box. It shouldn't stop you from being able to use .meta on the event, but it'll be a pain to add the notes or to edit them or look through them, without copying it all into a word processor or something.
Yeah, I agree that entering data into the note field in an event is a pain. I use the field as an 'event global', and comments for 'event local'. As for usage of notes, though ... meta is nice because all of the code is in the base. So, all someone has to do is nab whatever from the 'meta' property.