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] Load game in a different location than save.

Status
Not open for further replies.

Jereth

Member

I'm looking for a way so when a game is loaded, your character starts at a predefined location if a switch is enabled. What code, and where would I need to put it to have this work:

if (switch009 = on)
load chara, map_ID 24, x 20, y15

So if a switch is on, and you save, when you load the game you'll be on Map 24 at xy 20,15.
 
I haven't tested, but adding this script before Main shall do the trick.
Code:
class Scene_Load
  alias_method :jereth_scnload_read_save_data, :read_save_data
  def read_save_data(file)
    jereth_scnload_read_save_data(file)
    if $game_switches[[COLOR=Red]9[/COLOR]]
      $game_temp.player_transferring = true
      $game_temp.player_new_map_id = [COLOR=Red]24[/COLOR]
      $game_temp.player_new_x = [COLOR=Red]20[/COLOR]
      $game_temp.player_new_y = [COLOR=Red]15[/COLOR]
      $game_temp.player_new_direction = [COLOR=Red]8[/COLOR]
    end
  end
end
You can change the red numbers for anything you want.
 

Jereth

Member

I tried close to the same thing, the problem with that is if you put the script after the the original Scene_Load it loads the regular map then transports you to the new map, if you put it before, it simply can't find a call. However, I found a way to get the job done.

In the class Scene_load where the scripts reads:
Code:
        $game_map.setup($game_map.map_id)
        $game_player.center($game_player.x, $game_player.y)
I made an addition after it so it looks like this:
Code:
        $game_map.setup($game_map.map_id)
        $game_player.center($game_player.x, $game_player.y)
        if $game_switches[9]
          $game_map.setup(24)
          $game_temp.player_new_x = 20
          $game_temp.player_new_y = 15
          $game_player.moveto($game_temp.player_new_x, $game_temp.player_new_y)        end
This got rid of any errors I had any other way, it loads the normal load map, then is overridden by new ones if the switch is on.

Thanks for the help.
 
Status
Not open for further replies.

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