Swapping player and event positions

Hi! I was trying to make a simple way to swap places between an event and the player and found this post at the Steam Community:
https://steamcommunity.com/app/220700/discussions/0/541906989406046907/

Signum1221 wrote a simple script that almost did it:

Add this to script manager>materials section:
Code:
class Game_Map
  attr_accessor :events
end
class Game_Event
  attr_accessor :event
end

And this in the event:
Code:
#saves event position
coordx=$game_map.events[self.event_id].event.x
coordy=$game_map.events[self.event_id].event.y

#sets event position to player position
$game_map.events[self.event_id].moveto($game_player.x,$game_player.y)

#sets player position to old event position
$game_player.moveto(coordx,coordy)

You can also change "self.event_id" for any specific ID you want.

HOWEVER! As he stated:
There its a bug that im trying to solve now (event changes position to where player its but player changes position to starting event position) im trying to find the cause.

And there's was no fix to it... 😢 Any ideas on how to fix it?
Could you explain more? Or maybe take a screenshot? Or even better, record it.
The Steam link takes you to a discussion for VX Ace. You, however, have posted in VX. VX Ace scripts do not work in VX.

Have you posted in the right place? If it really is Ace you want, this thread will have to be moved.
$game_map.events[x].event takes you to the event's original setup, so yes, it will take you to the event's starting position.

Replace this:
Code:
coordx=$game_map.events[self.event_id].event.x
coordy=$game_map.events[self.event_id].event.y

with this:
Code:
coordx=$game_map.events[self.event_id].x
coordy=$game_map.events[self.event_id].y
$game_map.events[x].event takes you to the event's original setup, so yes, it will take you to the event's starting position.

Replace this:
Code:
coordx=$game_map.events[self.event_id].event.x
coordy=$game_map.events[self.event_id].event.y

with this:
Code:
coordx=$game_map.events[self.event_id].x
coordy=$game_map.events[self.event_id].y

That worked perfectly! Such a small change o.o
Thanks very much!!!

This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

Original thread: https://forums.rpgmakerweb.com/threads/swapping-player-and-event-positions.78845/