Return player using x, y and direction

Kes

Veteran
Veteran
Joined
Aug 3, 2012
Messages
22,299
Reaction score
11,712
First Language
English
Primarily Uses
RMVXA
Setup:
An item takes the player from the map where they are standing to another one. I use 3 variables to get them back to the same spot, one for the x, one for y, and one for the map ID. These are set in the normal way on the transfer out and used in the transfer event which sends them back.

However, I also want the player to be facing the same direction as when they left the first map but cannot see a straightforward way of establishing it in the first place.
I have thought of using 4 temporary variables with 4 conditional branches before the first transfer, so if e.g. the player is facing right, then one would be added to temp variable 2.
Then have 4 conditionals on the transfer back which would pick up which of those variables was higher than zero and use that to, in this example, turn right.
However, that seems incredibly cumbersome, and I'm wondering if there is a script call or something which I could use?

Thanks.
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
You can use Control Variables to retrieve the player's facing direction, in the same way as you get the map id, x and y locations.

Then add a script call as follows:
Code:
@params = [1, a, b, c, d, 0]
command_201
replacing a, b, c and d with the variable ids that contain the map number, x, y and direction. The 1 indicates you're using variables, and the 0 indicates the normal fade.

Also works if you have followers turned on.
 
  • Like
Reactions: Kes

Kes

Veteran
Veteran
Joined
Aug 3, 2012
Messages
22,299
Reaction score
11,712
First Language
English
Primarily Uses
RMVXA
@Shaz Thank you, this works just as I want it to.
Your help is much appreciated.

EDIT
@Shaz I've run into a problem.

When I transfer back the sprite is invisible until I move, then it is clearly there. I didn't notice it when I tested before because, I think, I must have nudged the mouse or arrowkey so that the sprite was visible before I realized that it wasn't (if you see what I mean).

You won't be surprised to read that I haven't a clue what to do about this.
 
Last edited:

Heirukichi

Veteran
Veteran
Joined
Sep 24, 2015
Messages
1,421
Reaction score
596
First Language
Italian
Primarily Uses
RMVXA
@Kes to me it looks like you are trying to display a non-existing sprite. That might explain why it is invisible until you move. If that is the case it might be caused by a wrong direction so when you move the engine automatically shows the sprite for the direction you are facing and everything is fixed.

How did you obtain player direction? Did you set player direction automatically ($game_player.direction)? Did you use conditional branches?

Of course this is the first thing that comes into my mind. The issue might lie somewhere else.
 

Kes

Veteran
Veteran
Joined
Aug 3, 2012
Messages
22,299
Reaction score
11,712
First Language
English
Primarily Uses
RMVXA
@Heirukichi I am using the script call given by Shaz 2 post up, having set the 4 variables (map id, player's x, player's y, player's direction) and using that script call instead of a normal transfer event. The player direction is taken from the ordinary Control Variable -> Game Data->Character->Player's Direction selections.
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
That sounds like an issue that people reported with my map edge transfer plugin. I'll go back to that and see what I had to do to solve the problem. However, we're packing/travelling today, so I'll either have to wait until we're all packed and I have some spare time, or until we arrive at the coast later today, to be able to look at it.

Hopefully you can put up with the issue for a little longer, until I have time to look at a fix :)
 

Heirukichi

Veteran
Veteran
Joined
Sep 24, 2015
Messages
1,421
Reaction score
596
First Language
Italian
Primarily Uses
RMVXA
@Kes just in case you have something that modified how that method works (command_201) try to use this:
Code:
$game_player.reserve_transfer(map, x, y, direction)
Fiber.yield while $game_player.transfer?
map is the variable you used to store your map id, x and y and variables used to store player coordinates and direction is the variable you used to store player direction. You should use them in the form $game_variables[id]. If it does not fit in a single line you can change it like this:
Code:
m = $game_variables[the_one_used_for_map_id]
px = $game_variables[the_one_used_for_player_x]
py = $game_variables[the_one_used_for_player_y]
pd = $game_variables[the_one_used_for_player_direction]
$game_player.reserve_transfer(map, px, py, pd)
Fiber.yield while $game_player.transfer?
Does the issue persist even if you use this?
 
  • Like
Reactions: Kes

Kes

Veteran
Veteran
Joined
Aug 3, 2012
Messages
22,299
Reaction score
11,712
First Language
English
Primarily Uses
RMVXA
@Heirukichi Sorry about the delay in getting back to you - RL intervened and I had no time to test.

Your solution works, I transfer back and am immediately visible.
Thank you very much for your help.
 

Heirukichi

Veteran
Veteran
Joined
Sep 24, 2015
Messages
1,421
Reaction score
596
First Language
Italian
Primarily Uses
RMVXA
I am glad that helped you. It seems the method you used previously (command_201) has been somehow modified by other scripts. By default it only contains those line I wrote and another line to check your fade type. Other lines are just checks to see if you are in battle, if there are messages etc.

Hopefully knowing the issue is related to that method can also help who wrote the script to fix that.
 

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

  • Latest Threads

    Latest Posts

    Latest Profile Posts

    How many parameters is 'too many'??
    Yay, now back in action Happy Christmas time, coming back!






    Back in action to develop the indie game that has been long overdue... Final Fallacy. A game that keeps on giving! The development never ends as the developer thinks to be the smart cookie by coming back and beginning by saying... "Oh bother, this indie game has been long overdue..." How could one resist such? No-one c
    So I was playing with filters and this looked interesting...

    Versus the normal look...

    Kind of gives a very different feel. :LZSexcite:
    To whom ever person or persons who re-did the DS/DS+ asset packs for MV (as in, they are all 48x48, and not just x2 the pixel scale) .... THANK-YOU!!!!!!!!! XwwwwX

    Forum statistics

    Threads
    105,853
    Messages
    1,016,990
    Members
    137,562
    Latest member
    tamedeathman
    Top