MV Conditional Script for Checking Event Name and Direction

I want to make a script for a conditional branch that does the following:
if every event that is named "0" is facing down, ....

I've done some research, but I've never used scripts before. The script I tried was:

"events":[{"name":"0","pages":[{"image":{"direction":8}}]}]

But, I am getting the error, "unexpected token" so I think it is something with the formatting, but I don't know ;(

How would I write this script?

Note: There are multiple events with the name "0" just to clarify
That doesn’t look like JavaScript at all. Where did you get it from?
I've done some research, but I've never used scripts before. The script I tried was:

"events":[{"name":"0","pages":[{"image":{"direction":8}}]}]
To be more specific, what you have is part of what is in the .json file of a map for events (in the data folder). You cannot use the data like that in a conditional branch as a script call without the proper references to the data.

You will need to use the script portion of the conditional branch event command:
JavaScript:
$gameMap.events().filter(e => e.event().name === '0').every(e => e.direction() === 2)
So it might look something like this in the event:
JavaScript:
◇If : Script : $gameMap.events().filter(e => e.event().name === '0').every(e => e.direction() === 2)

Side note: be cautious of using the name part of your events - if, for whatever reason your game needs to be translated, that part will need to be changed. Usually, references to the notes field is preferred for those cases.
To be more specific, what you have is part of what is in the .json file of a map for events (in the data folder). You cannot use the data like that in a conditional branch as a script call without the proper references to the data.

You will need to use the script portion of the conditional branch event command:
JavaScript:
$gameMap.events().filter(e => e.event().name === '0').every(e => e.direction() === 2)
So it might look something like this in the event:
JavaScript:
◇If : Script : $gameMap.events().filter(e => e.event().name === '0').every(e => e.direction() === 2)

Side note: be cautious of using the name part of your events - if, for whatever reason your game needs to be translated, that part will need to be changed. Usually, references to the notes field is preferred for those cases.
Ah I see that makes a lot more sense, and it worked! Thank you! And also thank you for the warning
That doesn’t look like JavaScript at all. Where did you get it from?
It technically is but it's a random snippet from an object. Just dumping it in a script call wouldn't do anything. Well, I guess you'd get a syntax error that would crash the game.

Original thread: https://forums.rpgmakerweb.com/threads/conditional-script-for-checking-event-name-and-direction.176560/