Change Map via scripting?

Started by jailuis, August 14, 2011, 12:12:47 pm

Previous topic - Next topic

jailuis

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 ^^

ForeverZer0

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.
I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.

jailuis

Thanks ^^! that worked.

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