How Do I Make a "Border Exit" Without Plopping a Bunch of Event Squares?

Davtwan

Greenhorn
Member
Joined
Feb 7, 2020
Messages
3
Reaction score
4
First Language
English
Primarily Uses
RMMV
I am currently running a "practice project" to learn how to use RPG Maker MV (currently v1.62). The starting town has no fencing around it due to the fact that it is a mostly destroyed town. However, to prevent confusion, I would have to make sure all the borders of the map lead to the overworld and not just the path.

I have tried to make the x and y coordinates of the player into variables so that when the player is at a certain variable (such as the one that would be y = 0), then the event will warp them into the overworld. For example, when the player touches the left edge of the map, then he'd warp to the overworld on the square that's left of the town square. However, the universal exit event has ended up making the player unable to move, probably because the auto-running event never truly "finishes."

I'm thinking of maybe using a script instead of a variable instead, but I don't know what the right $Game_Player that has the current x and y coordinates are. Is there a way to make the borders of a map into an exit with one event square, or am I just better off cutting my losses and fencing the town?
 
Last edited:

ImaginaryVillain

Resident of Silent Hill... Apparently
Veteran
Joined
Jun 22, 2019
Messages
714
Reaction score
3,729
First Language
Absurdism
Primarily Uses
RMMV
Place this code in a parallel event (using the script command) on the map where you want the border to act as a transfer. Replace mapId with the Id of the map you want to transfer to, and the x, y with the x,y where you want the player to end up at.


edit: The Pastebin insert messes up the code as well... Hmm... Just make certain line 1, and the line with no number below it are on the same line.
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
39,949
Reaction score
13,585
First Language
English
Primarily Uses
RMMV
Autorun event takes away control from the player. If you want something that runs continually in the background, make it a parallel process event instead. Make sure you put a Wait 10 Frames at the start of the event, because there's no way you need to check the player's location 60 times a second.
 

Davtwan

Greenhorn
Member
Joined
Feb 7, 2020
Messages
3
Reaction score
4
First Language
English
Primarily Uses
RMMV
Place this code in a parallel event (using the script command) on the map where you want the border to act as a transfer. Replace mapId with the Id of the map you want to transfer to, and the x, y with the x,y where you want the player to end up at.
Autorun event takes away control from the player. If you want something that runs continually in the background, make it a parallel process event instead. Make sure you put a Wait 10 Frames at the start of the event, because there's no way you need to check the player's location 60 times a second.
Thanks, you two. I feel silly realizing it's literally just the x and y values without any additional info I saw in the javascript library. I combined both your advice into one to make things easier to edit if I ever need to change the exit.

Exit-Script.png

For now it works as a north exit, but I'll see if I can combine more exits on the same event. If not, then four exits won't hurt that much.

Edit: Fantastic! The event doesn't seem confused by additional conditioning branches.
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
39,949
Reaction score
13,585
First Language
English
Primarily Uses
RMMV
Yes, you can combine them all, using nested conditions.

Code:
Wait 10 Frames
If Script: $gamePlayer.y === 0
  Transfer (to above map)
Else
  If Script: $gamePlayer.y === $dataMap.height - 1
    Transfer (to below map)
  Else
    If Script: $gamePlayer.x === 0
      Transfer (to left map)
    Else
      If Script: $gamePlayer.x === $dataMap.width - 1
        Transfer (to right map)
      End
    End
  End
End
 

Davtwan

Greenhorn
Member
Joined
Feb 7, 2020
Messages
3
Reaction score
4
First Language
English
Primarily Uses
RMMV
Yes, you can combine them all, using nested conditions.
Oh shoot. Thanks for reminding me. I didn't use the Else branches the first time around. That sounds more stable to do, so I'll definitely do that.
 

Bex

Veteran
Veteran
Joined
Aug 2, 2013
Messages
1,492
Reaction score
408
First Language
German
Primarily Uses
RMMV
In your Parallel Event, use the Eventcommand Conditional Branch and put this into the Scriptline:
$gamePlayer.regionId() === 1
if yes: Teleport

Now Paint Region 1 everywhere on the Map boarders where you want the Player to trigger the Teleport.

This could also be done with 100% Eventing, but Scriptsnippets are awesome, the RMMV Sciptcall list helped me with it.
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Profile Posts

I just like this website:
lol
I streamed Moonfall on 9/25/20
and have started a page to showcase my vids/stream :kaoluv:

Please subscribe and follow, it's free, it's quick and one sub means so much to me, it would really make my day~ :wub

And now to face my worst enemy... adding color :kaocry:

Forum statistics

Threads
103,234
Messages
998,246
Members
134,721
Latest member
isaton
Top