Player/Event barrier

Hi friends, this is normally something I have no trouble with but I need to know how to fix it to move on.

Basic rundown:
I have in my project two events that help operate my traffic lights-

Traffic Colour:
this event functions as the light effect destination that hovers above center of the road, it is only there to project the coloured light effect, the event itself has no graphic.

Traffic Light post/barrier: This event's sole responsibility is to control the flow of traffic, it acts as an invisible barrier on a tile to prevent NPC vehicles from passing when the lights go red.

THE PROBLEM:
I cannot figure out how to control it to allow players to move freely through it even when the light's go red forcing it to become an impassible barrier for NPC vehicles. If I set the page or movement to have THROUGH ON/OFF it will do it for both parties- I need to know how I can nit-pick at what events/players can pass through and when.

This seems trivial and I feel a long time ago I actually found a way through it- but to this day things have changed heavily since when I first started using MV.
Would this work? Put the red light page below characters for priority (no through). Players can pass, but NPC events can't.
belowCharO.gif
Ohh that GIF sure looks like what I'm after- I had followed your steps but my NPC who is on same level as player in terms of priorirty still passes through.
Does there happen to be another factor we are missing?
Is Through OFF for both red light and NPC?

If that's so, maybe a plugin causing is overriding this default behavior?
Got any plugin rewriting canPass or isPassable or something of that nature?
Though is checked off and same goes for the NPC, still proceeds through the barrier sadly :/
Checked thoroughly and I have 0 plugins effecting pass on/off functions :s

Could you provide screenshots for me? Not saying your side is wrong but I might be making the slightest mistake.
Plain and simple: below characters & same as characters (no through on either); now I'm worried if the Mac version behaves differently. I already assume that everybody else is on Windows.
Oh yes i'm using the windows version, I don't know if there are differences with Mac versions but if I'm emulating the same thing and it's not presenting the same results there may just be differences strangely enough, I've noticed you have a comment "<odd>"placed in the page- is this comment directed to a plugin?
I was practicing a comment solution to make certain events passable <odd> and <even>, but I had a no-brainer moment because it would basically equate to Through ON and Through OFF, just extra labor. The comment is vestigial. I never wrote the plugin because it would have been silly.

Are your other players moveable Events rather than gamePlayer?
I was practicing a comment solution to make certain events passable <odd> and <even>, but I had a no-brainer moment because it would basically equate to Through ON and Through OFF, just extra labor. The comment is vestigial. I never wrote the plugin because it would have been silly.

Are your other players moveable Events rather than gamePlayer?
As far as I can tell all the events that are commanded to move through this barrier event are self commanded to if that is what you mean. I'm compiling a few screenshots now (might of needed to do that earlier)
These are the pages of the traffic light barrier, the car NPC is just a standard same level as player even with no through options installed as he just goes back and forth to test through the barrier-with each still able to pass through sadly.
I came up with a plugin; you'll just have to modify it a bit to fit your needs.
throughthingo.gif

If the events of a certain characterName (People1 and People2 PNG, in this example) meet any event with self switch B on, then they can't pass.
PHP:
Game_CharacterBase.prototype.canPassDefault = Game_CharacterBase.prototype.canPass;
Game_CharacterBase.prototype.canPass = function(x, y, d) {
   var ev1 = $gameMap.eventsXy(x, y)[0];
   var ev2 = $gameMap.eventsXy(
       $gameMap.roundXWithDirection(x, d), // x2
       $gameMap.roundYWithDirection(y, d)  // y2
   )[0];
   var char1 = ev1 !== undefined && ev1._characterName !== undefined;
   var char2 = ev2 !== undefined && ev2._eventId !== undefined;
   if(char1 && char2){
       var blockMe = ev1._characterName.match(/People1|People2/g) !== null;
       var blockMeNow = $gameSelfSwitches.value([ev2._mapId,ev2._eventId,"B"]);
       if(blockMe && blockMeNow)
           return false;
   }
   return this.canPassDefault.apply(this,arguments);
};
Add something like this, below, to the char2 boolean to make it only the stoplight event and not all events with selfSwitch B on.
PHP:
var char2 = ev2 !== undefined && ev2._eventId !== undefined && ev2._characterName !== undefined && ev2._characterName === "stoplight"; //.png

I just hope your player cars aren't on the same PNG as your NPC cars.

It doesn't have to be the characterName if you'd like to pull up info like name from $dataMap instead.
Oooh I think this plugin would solve the issue, as for regards to the graphics chosen and such that should be handy.
The NPCs that walk the streets are spawned events that use various plugins to select there race and apearence out of the 8 types per 8 sheets of that race, as for vehicles they follow a similar method- when a spawn timer allows them to show on map they choose a graphic, pathway and speed, essentially they are the only ones who really matter when it comes to the traffic barriers.

As much as I would love to try this plugin out- I can't seem to get the correct data on file- would you be able to upload the file for me?
Terribly sorry for being horrible at this :s
Ok. I took all the script stuff to edit and put it into parameters.

If your cloned events are named like car1,car2,car3... StopEventName "car" will stop all cars, but it will also stop an event named "careless", because it has car in it (regex greed).

StopCharacterName is a little more safe as it will block specifically by the png characterName.

AtCharacterName is the characterName png of the event with the selfSwitch to stop on. I kinda figured the event might have (none) so you might wanna use AtEventName like stoplight,pothole,etc all stoplight1,stoplight2,stoplight3 will be stopping things.

AtSelfSwitch is the selfSwitch.

Leave parameters blank and they shouldn't effect the outcome, unless you leave them all blank, in which case turn off the plugin because it will probably just corrupt canPass, and it's pry not needed without a parameter.

I'm not good at making plug and play stuff.
This works wonderfully with the vehicles! At the moment I have the plugin block off cars with the event name "Car Event" as they are the only events that obey the traffic laws, NPC vehicles that do not follow the laws obviously will ignore the barriers given.

I performed another test with the inclusion of pedestrian to see if it will past the barrier when on red light- which in terms means the crosswalk would be at it's safest to traverse through- however leaving the plugin parameters blank I think from your instructions meant that events not listed would simply ignore the barriers and walk through like normal- however that is not the case as the pedestrian is also blocked. It isn't an important thing for my project but for the plugins sake of 100% functionality is there something I am doing wrong?

Like I do with everyone that helps me- I will gladly make you an addition to the credits page 🙂
I forgot to mention: turn Through On for the red light page, now that the plugin handles canPass anyway, it shouldn't matter for other events. The pedestrian might have finally caught that same level as characters priority burp that I was trying to get at in my first post.

EDIT: I just tested and it should work.
pass3way-o.gif
I hate to give you bad news but adding that through option on the same page has not allowed the predestriant to move through, the predestrian just had standard same level as player, but is still blocked.
This might be caused by Mac/PC versions?
What is the pedestrian's PNG name? Is it on the same charset as the cars?
Untitled-o.gif

I was watching some girl's MV event tutorials, and I recall she mentioned that in MV events will crossover events so you can't really use the hidden event method anymore to block events, and I tested this and it seems that's incorrect, but you've confirmed that MV events actually will crossover events, and now my plugin to correct this has completely reversed the rule somehow...
@Skurge
Can you post a screenshot of your parameters page? I think I've might have made a mistake in my explanation of something.
Hm, I think by default RPG Maker MV is capable of having events cross over each other but only when through is ticked on.

Typically the pedestrians that will be used in the final product are "Pedestrian SPAWN"
But for the standard test pedestrian that walks left and right is "pred"

Here is the screen cap of the parameters, it's most likely me making a slight mistake, there are blanks left in the page because I didn't want to specify what else the traffic light barrier stops.
Just an FYI, if I remember correctly events being unable to pass through other events with "below characters" priority was a bug that was fixed in an earlier version of MV. It's possible that the Mac version hasn't had that fix yet.
I see. It's the comma.

In my shoddy string to regex, I made a comma becomes a "|" seperator which if not followed by anything, matches everything.
Screen%20Shot%202017-03-23%20at%204.25.39%20AM.png


I should have just said (takes escaped regex)

Take the comma off of Car Event, unless you plan on adding more event names.

Original thread: https://forums.rpgmakerweb.com/threads/player-event-barrier.76237/