Player and Event movement in script

Here is a quick way to have the player (or event) move around via a script call:

Code:
  # Direction [2]Down [4]Left [6]Right [8]Up

  # To change player direction:
  # $game_player.set_direction(8)

  # To change event direction:
  # $game_map.events[ID].move_straight(4)

  def move_player
    # Move the player
    $game_player.move_straight(4)

    # Move the event
    $game_map.events[ID].move_straight(4)
  end

[ID] ID is the event ID you want to move
To get the event ID click on the event and look at the bottom right of the VX Ace window

Example: 030: Jean as Teacher
030 is the Event ID and 'Jean as Teacher' is the event name

I thought I would share this in case anyone would find this useful.

Notes: Setting Player/Event direction before you move isn't necessary because the player/event will automatically change to the direction for the move.

This may fall under catagory of 'tutorial', and if so feel free to move it there.

Original thread: https://forums.rpgmakerweb.com/threads/player-and-event-movement-in-script.102896/