Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

[Resolved] Scroll Back Script

JoshC

Member

Ok, I need a script or a link to a script that will transfer the player to the opposite side of a map when they reach the edge. In essence making the map like a sphere. So once they touch the edge it will transfer them to the opposite side of the map at the next set coords. i.e. if the map is a 15x15, and they get to point 15,9 it will transfer them to 0,9; you get the idea. I'd just do this with events but my map is a 500x500. Sorry I'm not making a couple thousand events for that.
 
Try this (insert above Main)
[rgss]#==============================================================================
# ** Wrapped Maps (Movement)
#------------------------------------------------------------------------------
# SephirothSpawn
# Version 0.1
# 2009-02-09 (Year-Month-Day)
#==============================================================================
 
class Game_Character
  Wrapped_Maps = [1]
  Wrapped_Maps_Events = true
  alias_method :seph_wrappedmaps_gmchr_md, :move_down
  def move_down(turn_enabled = true)
    turn_down if turn_enabled
    if @y == $game_map.height - 1 && Wrapped_Maps.include?($game_map.map_id)
      if self.is_a?(Game_Player)
        seph_trans_moveto(@x, 0)
        return
      elsif Wrapped_Maps_Events
        moveto(@x, 0)
        return
      end
    end
    seph_wrappedmaps_gmchr_md(turn_enabled)
  end
  alias_method :seph_wrappedmaps_gmchr_ml, :move_left
  def move_left(turn_enabled = true)
    turn_left if turn_enabled
    if @x == 0 && Wrapped_Maps.include?($game_map.map_id)
      if self.is_a?(Game_Player)
        seph_trans_moveto($game_map.width - 1, @y)
        return
      elsif Wrapped_Maps_Events
        moveto($game_map.width - 1, @y)
        return
      end
    end
    seph_wrappedmaps_gmchr_ml(turn_enabled)
  end
  alias_method :seph_wrappedmaps_gmchr_mr, :move_right
  def move_right(turn_enabled = true)
    turn_right if turn_enabled
    if @x == $game_map.width - 1 && Wrapped_Maps.include?($game_map.map_id)
      if self.is_a?(Game_Player)
        seph_trans_moveto(0, @y)
        return
      elsif Wrapped_Maps_Events
        moveto(0, @y)
        return
      end
    end
    seph_wrappedmaps_gmchr_mr(turn_enabled)
  end
  alias_method :seph_wrappedmaps_gmchr_mu, :move_up
  def move_up(turn_enabled = true)
    turn_up if turn_enabled
    if @y == 0 && Wrapped_Maps.include?($game_map.map_id)
      if self.is_a?(Game_Player)
        seph_trans_moveto(@x, $game_map.height - 1)
        return
      elsif Wrapped_Maps_Events
        moveto(@x, $game_map.height - 1)
        return
      end
    end
    seph_wrappedmaps_gmchr_mu(turn_enabled)
  end
  def seph_trans_moveto(x, y, map_id = $game_map.map_id)
    $game_temp.player_transferring = true
    $game_temp.player_new_map_id = map_id
    $game_temp.player_new_x = x
    $game_temp.player_new_y = y
    Graphics.freeze
    $game_temp.transition_processing = true
    $game_temp.transition_name = ''
  end
end
[/rgss]

To make a map wrappable, add the map id # in the Wrapped_Maps = [1] list. To make events able to go from side to side as well, make Wrapped_Maps_Events = true (false to make it so events can't go from side to side).

Let me know how it works.
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top