Set map scrolling limits

I'm looking for a script to manually limit how far the camera will go while the player is walking around the field. For example, I have an "L" shaped map and in the lower left corner there is a portion I am not using because I have blocked it out for a town. Due to the event-heavy nature of the town, I am creating a separate map for it. This leave me with a large black portion (I have blocked it out in black) that I would like to prevent the camera from scrolling onto. I would like to control the camera's movement to cause it to react the same way it would if it were to collide with the edge of the prescribed map parameters (the edge of any given map).

I have attached the relevant map section I described above. I have marked where I located my town during the drafting phase of my map. I wish to prevent the camera from scrolling onto the black area as the player explores. I would like to also be able to use the script on other maps, as this is an issue I will be having a lot.

game map.png
What if the player is at the bottom right of your map, goes left to the edge of the black area, but he then moves up at the edge until the black is no longer blocking the camera? It would suddenly jump back to following him, that would be disorientating no?

If possible, I would recommend filling in the black area with just the map of the village (no events), and deal with transfers in the normal way. This is the way a lot of RPG games work, including the Elder Scrolls.

If not, then fine, I just thought I'd mention that.

Original thread: https://forums.rpgmakerweb.com/threads/set-map-scrolling-limits.18629/