Chaos Project

RPG Maker => RPG Maker Scripts => Script Troubleshooting => Topic started by: jailuis on August 14, 2011, 12:12:47 pm

Title: Change Map via scripting?
Post by: jailuis on August 14, 2011, 12:12:47 pm
Hi. Im working on RGSS (RPG Maker XP) and I want to change location using scripts. Yeah, i know there is the "teleport" command, but i want an event to actually teleport you somewhere using the "Call Script" command. This is because Im trying to create a Menu using a Map, But i can't figure out how to teleport myself to a map when pressing X button.

I suppose it must be related to the Scene_Map.new variable... But... how can i specify a map to teleport to (and the coordinates) using that?

--Hope everyone can understand--

Thanks for the help ^^
Title: Re: Change Map via scripting?
Post by: ForeverZer0 on August 14, 2011, 03:36:10 pm
class Game_Map
 
  def transfer(map_id, x, y, dir = nil, fade = true)
    $game_temp.player_new_map_id = map_id
    $game_temp.player_new_x = x
    $game_temp.player_new_y = y
    $game_temp.player_new_direction = dir if dir != nil
    if fade
      Graphics.freeze
      $game_temp.transition_processing = true
      $game_temp.transition_name = ''
    end
    $game_temp.player_transferring = true
  end
end


Use this syntax to call:
$game_map.transfer(MAP_ID, X, Y, DIRECTION, FADE)

MAP_ID, X, and Y are all pretty self-explanatory
DIRECTION and FADE are optional arguments that can be supplied. DIRECTION is a value of 2, 4, 6, or 8 that corresponds to the direction they should face.  They direction will not be changed if this value is omitted.  FADE is a true/false value to determine if a transition will be applied to the transfer, and will be used if no value is passed.
Title: Re: Change Map via scripting?
Post by: jailuis on August 14, 2011, 09:17:09 pm
Thanks ^^! that worked.

Now let's see if I can actually make what i want work.