Player/Event barrier

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 do recall something like this happening several months ago- I guess it didn't catch my attention to much because it wasn't an issue for me at the time.

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.
Ah fantastic! that seems to clear things up- so it all came down to the comma 🙂
Does the comma allow more restrictions on self switches? I think through tests it only will allow one self switch.
I probably should have made multiple selfswitches, but I figured on just 1 because there are only 4.
Ah fair call 🙂 I really like this plugin, thank you so much for helping me out!
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.
It's probably not all Macs. It's probably just my Mac. That isn't the only bug I'm dealing with.
i'll be happy to test out any bugs for you- as far as i know the only thing was multiple switches but that isn't exactly a bug.
Replace this line after if(param.AtSelfSwitch !== "")
PHP:
           blockMeNow = blockMeNow && $gameSelfSwitches.value(
               [ev2._mapId,ev2._eventId,param.AtSelfSwitch]
           );
with this
PHP:
           if(param.AtSelfSwitch.length === 1){
               blockMeNow = blockMeNow && $gameSelfSwitches.value(
                   [ev2._mapId,ev2._eventId,param.AtSelfSwitch]
               );
           }else{
               var abcd = param.AtSelfSwitch.split(",");
               for(var i = 0; i < abcd.length; i++)
                   abcd[i] = $gameSelfSwitches.value(
                       [ev2._mapId,ev2._eventId,abcd[i]]
                   );
               blockMeNow = blockMeNow && abcd.indexOf(true) !== -1;
           }
and you should have a comma separated selfSwitch parameter.
EDIT: I attached it.
Just woke up and used the new additions! It's a success!

Had an extra self switch enabled witch allowed me to do the following:
  • Page Default Green light- passable-999 frame wait- selfswitch A ON
  • Page A Yellow light- passable-200 frame wait- selfswitch B ON
  • Page B Red light-impassable-999 frame wait- selfswitch C ON
  • Page C Green light-impassable-60 frame wait- selfswitch A/B/C OFF- Brief green light simulating vehicles preparing to accelerate Reverts back to default page
Absolutely adoring this plugin and how it's allowed me to compress work loads with various events, one final thing remains which I just realized.
On cross roads/intersections etc there are opposite side traffic lights which essentially do the same thing but opposite barrier timings where one traffic light starts green- the other starts red to perform safe traffic control. How would you go about making the barrier rules for one and for another which would require it's functions to operate on different self switch pages?
My guess is to use the same switches, but different timings, or else just parallel process one event to turn on all the odd or even self switches so their timings aren't in sync.

Using this getEventsByName function that I just built in a plugin... (a plugin of handy functions I'm now considering creating)
PHP:
var RPGMakerMV = RPGMakerMV || {};
RPGMakerMV.getEventsByName = function(name){
  var events = [];
  for(var i = 0; i < $dataMap.events.length; i++){
    if($dataMap.events[i] === null) continue;
    if($dataMap.events[i].name !== undefined && $dataMap.events[i].name === name)
      events.push($gameMap._events[$dataMap.events[i].id]);
  }
  return events;
}
...you could do something like this for all the odd stop lights, named "traffic light odd", on a self-erasing parallel process event to have half of the lights already on by self switch and out of sync with the even ones.
PHP:
var odd = RPGMakerMV.getEventsByName("traffic light odd"); // example event name
for(var i = 0; i < odd.length; i++)
   $gameSelfSwitches.setValue([odd[i]._mapId,odd[i]._eventId,"B"],true);
These are script commands correct? Sorry for being a pain in the arse but i'm not sure how to implement those. 🙁
The first one is a plugin.

The second one is a script call in an event.
Which program are you using to edit the plugins with? Notepad which usually lets me edit said plugins is not showing the full code for me.
You mean the SpecialPassable.js?

Notepad might render my Mac newlines without carriage returns.

Best use a code editor like Notepad++ or Atom.
Yeah I tried to open the specialpass js but the note pad I have won't open it probably because of the Mac version you have built it off on.
I'll have to try get a free version if there exists one to see if I can make the changes, I think the most easiest way for me to configure the opposite functioning lights would be with the modifications.
It's not so much a mac "version" as it is just a js file. Notepad uses \r for newlines where browsers make use of \r and \n (saves my butt if I forget a semicolon), but as far as I know most script editors simply use \n. I'm not 100% certain. This is just something I notice when opening text/plain files from my Mac in Windows Notepad.

Here, I'll add a plugin download of the getEventsByName so you don't have to edit it into the other plugin with Notepad. I got the idea from HTML.

Now you can call this by event script to turn half the streetlights on at first. As long as your timing is the same, even lights will be red when odd lights will be green. I used the name "traffic light odd" so you'll have to change that part; I don't know what you are naming the special lights.
PHP:
var odd = RPGMakerMV.getEventsByName("traffic light odd");
for(var i = 0; i < odd.length; i++)
   $gameSelfSwitches.setValue([odd[i]._mapId,odd[i]._eventId,"B"],true);
Oh for the other traffic lights that start of red they are named "TRAFFIC LIGHT ODD"
My other traffic lights function like this:

I've downloaded the handymanfunctions js but because this event is structured differently as written below in the dot points I am unsure how to implement the script call and how to address the impassable pages considering the default page is a barrier in opposition to the normal traffic lights.
  • Page Default Red light- impassable-999 frame wait- selfswitch A ON (supposed to be impassable at this point in opposition to the first traffic light)
  • Page A Green light-impassable-60 frame wait- selfswitch B ON- Brief green light simulating vehicles preparing to accelerate
  • Page B Green light- passable-999 frame wait- selfswitch C ON
  • Page C Yellow light-passable-200 frame wait- selfswitch A/B/C OFF
  • Reverts back to default page
Oh, I see. You already did different pages with different switches in different events. I was thinking the lights all had the same pages. I was hoping they all had the same switch pages. That way the odd lights could start on the switch page with event script.

Scrap that MyHandyFunctions.js, unless you ever need the getEventsByName. That plugin is a work in progress. It needs more functions.

I've modified the SpecialPassable parameters to do a second set of different block-at.
twolights-o.gif

The blocking events in this gif are only in sync for image size purposes. They are independent of eachother.

This is a different version, so make note of your parameters; I think they'll get reset to default.

I've added AtCharacterName2, AtEventName2, AtSelfSwitch2 and they act the same as the first ones.

In my opinion it's getting a bit convoluted; It's totally a custom script at this point, and I'm really not good at plug-and-play stuff. I think it would be easier to edit the javascript than to rely on my weirdly built parameters. I've gone from about 20 lines to 150 with these parameters. I think other people might get the first two versions, because IMO it would make sense to just use 1 or 2 switches and if other events need out of sync, then simply change their switches by event, but now this way you won't have to redo your whole city.
I thank you immensely for making edits to make my life easier, it's really appreciated.
But to make a quick question regarding the update: does the #2 parameters require there own stop event name?
My reason asking this is because the car event still passes through the event.
You can use one name for both using the name parameter, but my humble script can't handle that logic. It would block for all four switches.
Oh bugger me-the unthinkable had occurred, false alarm it was my stupid second car event that was incorrectly spelt.
Problem is now fixed! This is brilliant- I can have two separate traffic lights functioning to perfection now- this is a huge step forward for me because almost every over world/city street map has one of them active and to include active vehicles and predestrians using the traffic is an awesome thing to really bring out the urban atmosphere!

I really want to add you to the credits and I hope you'll accept that 🙂
I should of done this earlier and presented some screenshots but here we go:
Also note the traffic system is using Australian road rules so cars drive on the left side of the road with the wheel on the right- obviously the police are not following them for this example haha.

EDIT: There might be an issue with the 2# Traffic barrier's second self switch function, the first one selected blocks, but the second one does not.
That looks sweet! It reminds me of the the first Road Warrior movie because you mention Australia and it's law breakers and cops.

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