Jump to content
New account registrations are disabed. This website is now an archive. Read more here.
EmilyAnnCoons

Emily-Ann's Import-Export System

Recommended Posts

Ever want to take your characters from one game and import them into a sequel instead of falling to the typical "Let's start all over again" cliche? Now you can! This system will let you set up an export from one game, then allow you to import that file into the next game, thus allowing your players to start up right where they left off, with the same characters, and the same stats. This is a demo to show it works (I've tested it). I hope you enjoy it.

 

This system is rather easy to use. Simply edit Scene_Title with the following code (only needed for the game being imported to).

Scene_Title Edit

#==============================================================================
# ** Scene_Title
#------------------------------------------------------------------------------
#  This class performs title screen processing.
#==============================================================================

class Scene_Title
 #--------------------------------------------------------------------------
 # * Main Processing
 #--------------------------------------------------------------------------
 def main
# If battle test
if $BTEST
  battle_test
  return
end
# Load database
$data_actors		= load_data("Data/Actors.rxdata")
$data_classes	   = load_data("Data/Classes.rxdata")
$data_skills		= load_data("Data/Skills.rxdata")
$data_items		 = load_data("Data/Items.rxdata")
$data_weapons	   = load_data("Data/Weapons.rxdata")
$data_armors		= load_data("Data/Armors.rxdata")
$data_enemies	   = load_data("Data/Enemies.rxdata")
$data_troops		= load_data("Data/Troops.rxdata")
$data_states		= load_data("Data/States.rxdata")
$data_animations	= load_data("Data/Animations.rxdata")
$data_tilesets	  = load_data("Data/Tilesets.rxdata")
$data_common_events = load_data("Data/CommonEvents.rxdata")
$data_system		= load_data("Data/System.rxdata")
# Make system object
$game_system = Game_System.new
# Make title graphic
@sprite = Sprite.new
@sprite.bitmap = RPG::Cache.title($data_system.title_name)
#--------------------------------------------------------------------------
# Edit start
#--------------------------------------------------------------------------
# Make command window
s1 = "New Game"
s2 = "Import"
s3 = "Continue"
s4 = "Shutdown"
@command_window = Window_Command.new(192, [s1, s2, s3, s4])
@command_window.back_opacity = 160
@command_window.x = 320 - @command_window.width / 2
@command_window.y = 288
# Continue enabled determinant
# Check if at least one save file exists
# If enabled, make @continue_enabled true; if disabled, make it false
@continue_enabled = false
for i in 0..3
  if FileTest.exist?("Save#{i+1}.rxdata")
	@continue_enabled = true
  end
  if FileTest.exist?("E#{i+1}.export")
	@import_enabled = true
  end
end
# If continue is enabled, move cursor to "Continue"
# If disabled, display "Continue" text in gray
if @continue_enabled
  @command_window.index = 2
else
  @command_window.disable_item(2)
end
if @import_enabled
  @command_window.index = 1
else
  @command_window.disable_item(1)
end
#--------------------------------------------------------------------------
# Edit end
#--------------------------------------------------------------------------
# Play title BGM
$game_system.bgm_play($data_system.title_bgm)
# Stop playing ME and BGS
Audio.me_stop
Audio.bgs_stop
# Execute transition
Graphics.transition
# Main loop
loop do
  # Update game screen
  Graphics.update
  # Update input information
  Input.update
  # Frame update
  update
  # Abort loop if screen is changed
  if $scene != self
	break
  end
end
# Prepare for transition
Graphics.freeze
# Dispose of command window
@command_window.dispose
# Dispose of title graphic
@sprite.bitmap.dispose
@sprite.dispose
 end
 #--------------------------------------------------------------------------
 # * Frame Update
 #--------------------------------------------------------------------------
 def update
# Update command window
@command_window.update
# If C button was pressed
if Input.trigger?(Input::C)
  # Branch by command window cursor position
  case @command_window.index
  when 0  # New game
	command_new_game
  #---------------------------------------------------------------------
  # Edit Start
  #---------------------------------------------------------------------
  when 1  # Import
	command_import
  when 2  # Continue
	command_continue
  when 3  # Shutdown
	command_shutdown
  end
end
 end
 #---------------------------------------------------------------------
 # Edit End
 #---------------------------------------------------------------------
 #--------------------------------------------------------------------------
 # * Command: New Game
 #--------------------------------------------------------------------------
 def command_new_game
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Stop BGM
Audio.bgm_stop
# Reset frame count for measuring play time
Graphics.frame_count = 0
# Make each type of game object
$game_temp		  = Game_Temp.new
$game_system		= Game_System.new
$game_switches	  = Game_Switches.new
$game_variables	 = Game_Variables.new
$game_self_switches = Game_SelfSwitches.new
$game_screen		= Game_Screen.new
$game_actors		= Game_Actors.new
$game_party		 = Game_Party.new
$game_troop		 = Game_Troop.new
$game_map		   = Game_Map.new
$game_player		= Game_Player.new
# Set up initial party
$game_party.setup_starting_members
# Set up initial map position
$game_map.setup($data_system.start_map_id)
# Move player to initial position
$game_player.moveto($data_system.start_x, $data_system.start_y)
# Refresh player
$game_player.refresh
# Run automatic change for BGM and BGS set with map
$game_map.autoplay
# Update map (run parallel process event)
$game_map.update
# Switch to map screen
$scene = Scene_Map.new
 end
 #--------------------------------------------------------------------------
 # Addition Start
 #--------------------------------------------------------------------------
 #--------------------------------------------------------------------------
 # * Command: Import
 #--------------------------------------------------------------------------
 def command_import
# If Import is disabled
unless @import_enabled
  # Play buzzer SE
  $game_system.se_play($data_system.buzzer_se)
  return
end
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Switch to load screen
$scene = Scene_Import.new
 end
 #--------------------------------------------------------------------------
 # Addition End
 #--------------------------------------------------------------------------
 #--------------------------------------------------------------------------
 # * Command: Continue
 #--------------------------------------------------------------------------
 def command_continue
# If continue is disabled
unless @continue_enabled
  # Play buzzer SE
  $game_system.se_play($data_system.buzzer_se)
  return
end
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Switch to load screen
$scene = Scene_Load.new
 end
 #--------------------------------------------------------------------------
 # * Command: Shutdown
 #--------------------------------------------------------------------------
 def command_shutdown
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Fade out BGM, BGS, and ME
Audio.bgm_fade(800)
Audio.bgs_fade(800)
Audio.me_fade(800)
# Shutdown
$scene = nil
 end
 #--------------------------------------------------------------------------
 # * Battle Test
 #--------------------------------------------------------------------------
 def battle_test
# Load database (for battle test)
$data_actors		= load_data("Data/BT_Actors.rxdata")
$data_classes	   = load_data("Data/BT_Classes.rxdata")
$data_skills		= load_data("Data/BT_Skills.rxdata")
$data_items		 = load_data("Data/BT_Items.rxdata")
$data_weapons	   = load_data("Data/BT_Weapons.rxdata")
$data_armors		= load_data("Data/BT_Armors.rxdata")
$data_enemies	   = load_data("Data/BT_Enemies.rxdata")
$data_troops		= load_data("Data/BT_Troops.rxdata")
$data_states		= load_data("Data/BT_States.rxdata")
$data_animations	= load_data("Data/BT_Animations.rxdata")
$data_tilesets	  = load_data("Data/BT_Tilesets.rxdata")
$data_common_events = load_data("Data/BT_CommonEvents.rxdata")
$data_system		= load_data("Data/BT_System.rxdata")
# Reset frame count for measuring play time
Graphics.frame_count = 0
# Make each game object
$game_temp		  = Game_Temp.new
$game_system		= Game_System.new
$game_switches	  = Game_Switches.new
$game_variables	 = Game_Variables.new
$game_self_switches = Game_SelfSwitches.new
$game_screen		= Game_Screen.new
$game_actors		= Game_Actors.new
$game_party		 = Game_Party.new
$game_troop		 = Game_Troop.new
$game_map		   = Game_Map.new
$game_player		= Game_Player.new
# Set up party for battle test
$game_party.setup_battle_test_members
# Set troop ID, can escape flag, and battleback
$game_temp.battle_troop_id = $data_system.test_troop_id
$game_temp.battle_can_escape = true
$game_map.battleback_name = $data_system.battleback_name
# Play battle start SE
$game_system.se_play($data_system.battle_start_se)
# Play battle BGM
$game_system.bgm_play($game_system.battle_bgm)
# Switch to battle screen
$scene = Scene_Battle.new
 end
end

 

Then put in these four scripts. (Note: In the first game, you will need to put in everything up to Export. In the second game, where you plan to import, you will need all 4).

Window_ExportFile

#==============================================================================
# ** Window_ExportFile
#------------------------------------------------------------------------------
#  This window displays save files on the Export and Import screens.
#==============================================================================

class Window_ExportFile < Window_Base
 #--------------------------------------------------------------------------
 # * Public Instance Variables
 #--------------------------------------------------------------------------
 attr_reader   :exportname			   # file name
 attr_reader   :selected				 # selected
 #--------------------------------------------------------------------------
 # * Object Initialization
 #	 file_index : save file index (0-3)
 #	 filename   : file name
 #--------------------------------------------------------------------------
 def initialize(file_index, exportname)
super(0, 64 + file_index % 4 * 104, 640, 104)
self.contents = Bitmap.new(width - 32, height - 32)
@file_index = file_index
@exportname = "E#{@file_index + 1}.export"
@file_exist = FileTest.exist?(@exportname)
if @file_exist
  export = File.open(@exportname, "r")
  @characters = Marshal.load(export)
  @frame_count = Marshal.load(export)
  @game_system = Marshal.load(export)
  @game_switches = Marshal.load(export)
  @game_variables = Marshal.load(export)
  export.close
end
refresh
@selected = false
 end
 #--------------------------------------------------------------------------
 # * Refresh
 #--------------------------------------------------------------------------
 def refresh
self.contents.clear
# Draw file number
self.contents.font.color = normal_color
name = "Export #{@file_index + 1}"
self.contents.draw_text(4, 0, 600, 32, name)
@name_width = contents.text_size(name).width
# If save file exists
if @file_exist
  # Draw character
  for i in 0...@characters.size
	bitmap = RPG::Cache.character(@characters[i][0], @characters[i][1])
	cw = bitmap.rect.width / 4
	ch = bitmap.rect.height / 4
	src_rect = Rect.new(0, 0, cw, ch)
	x = 300 - @characters.size * 32 + i * 64 - cw / 2
	self.contents.blt(x, 68 - ch, bitmap, src_rect)
  end
  end
 end
 #--------------------------------------------------------------------------
 # * Set Selected
 #	 selected : new selected (true = selected, false = unselected)
 #--------------------------------------------------------------------------
 def selected=(selected)
@selected = selected
update_cursor_rect
 end
 #--------------------------------------------------------------------------
 # * Cursor Rectangle Update
 #--------------------------------------------------------------------------
 def update_cursor_rect
if @selected
  self.cursor_rect.set(0, 0, @name_width + 8, 32)
else
  self.cursor_rect.empty
end
 end
end

 

Scene_ExportFile

#==============================================================================
# ** Scene_ExportFile
#------------------------------------------------------------------------------
#  This is a superclass for the Import screen and Export screen.
#==============================================================================

class Scene_ExportFile
 #--------------------------------------------------------------------------
 # * Object Initialization
 #	 help_text : text string shown in the help window
 #--------------------------------------------------------------------------
 def initialize(help_text)
@help_text = help_text
 end
 #--------------------------------------------------------------------------
 # * Main Processing
 #--------------------------------------------------------------------------
 def main
# Make help window
@help_window = Window_Help.new
@help_window.set_text(@help_text)
# Make save file window
@exportfile_windows = []
for i in 0..3
  @exportfile_windows.push(Window_ExportFile.new(i, make_exportname(i)))
end
# Select last file to be operated
@file_index = $game_temp.last_file_index
@exportfile_windows[@file_index].selected = true
# Execute transition
Graphics.transition
# Main loop
loop do
  # Update game screen
  Graphics.update
  # Update input information
  Input.update
  # Frame update
  update
  # Abort loop if screen is changed
  if $scene != self
	break
  end
end
# Prepare for transition
Graphics.freeze
# Dispose of windows
@help_window.dispose
for i in @exportfile_windows
  i.dispose
end
 end
 #--------------------------------------------------------------------------
 # * Frame Update
 #--------------------------------------------------------------------------
 def update
# Update windows
@help_window.update
for i in @exportfile_windows
  i.update
end
# If C button was pressed
if Input.trigger?(Input::C)
  # Call method: on_decision (defined by the subclasses)
  on_decision(make_exportname(@file_index))
  $game_temp.last_file_index = @file_index
  return
end
# If B button was pressed
if Input.trigger?(Input::B)
  # Call method: on_cancel (defined by the subclasses)
  on_cancel
  return
end
# If the down directional button was pressed
if Input.repeat?(Input::DOWN)
  # If the down directional button pressed down is not a repeat,
  # or cursor position is more in front than 3
  if Input.trigger?(Input::DOWN) or @file_index < 3
	# Play cursor SE
	$game_system.se_play($data_system.cursor_se)
	# Move cursor down
	@exportfile_windows[@file_index].selected = false
	@file_index = (@file_index + 1) % 4
	@exportfile_windows[@file_index].selected = true
	return
  end
end
# If the up directional button was pressed
if Input.repeat?(Input::UP)
  # If the up directional button pressed down is not a repeat、
  # or cursor position is more in back than 0
  if Input.trigger?(Input::UP) or @file_index > 0
	# Play cursor SE
	$game_system.se_play($data_system.cursor_se)
	# Move cursor up
	@exportfile_windows[@file_index].selected = false
	@file_index = (@file_index + 3) % 4
	@exportfile_windows[@file_index].selected = true
	return
  end
end
 end
 #--------------------------------------------------------------------------
 # * Make File Name
 #	 file_index : export file index (0-3)
 #--------------------------------------------------------------------------
 def make_exportname(file_index)
return "E#{file_index + 1}.export"
 end
end

 

Scene_Export

#==============================================================================
# ** Scene_Export
#------------------------------------------------------------------------------
#  This class performs Export screen processing.
#==============================================================================

class Scene_Export < Scene_ExportFile
 #--------------------------------------------------------------------------
 # * Object Initialization
 #--------------------------------------------------------------------------
 def initialize
super("Which file would you like to export to?")
 end
 #--------------------------------------------------------------------------
 # * Decision Processing
 #--------------------------------------------------------------------------
 def on_decision(exportname)
# Play save SE
$game_system.se_play($data_system.save_se)
# Write save data
export = File.open(exportname, "wb")
write_save_data(export)
export.close
# If called from event
if $game_temp.save_calling
  # Clear save call flag
  $game_temp.save_calling = false
  # Switch to map screen
  $scene = Scene_Title.new
  return
end
# Switch to map screen
  $scene = Scene_Title.new
end
 #--------------------------------------------------------------------------
 # * Cancel Processing
 #--------------------------------------------------------------------------
 def on_cancel
# Play cancel SE
$game_system.se_play($data_system.cancel_se)
# If called from event
if $game_temp.save_calling
  # Clear save call flag
  $game_temp.save_calling = false
  # Switch to map screen
  $scene = Scene_Title.new
  return
end
# Switch to map screen
  $scene = Scene_Title.new
 end
 #--------------------------------------------------------------------------
 # * Write Save Data
 #	 file : write file object (opened)
 #--------------------------------------------------------------------------
 def write_save_data(export)
# Make character data for drawing save file
characters = []
for i in 0...$game_party.actors.size
  actor = $game_party.actors[i]
  characters.push([actor.character_name, actor.character_hue])
end
# Write character data for drawing save file
Marshal.dump(characters, export)
# Save magic number
# (A random value will be written each time saving with editor)
$game_system.magic_number = $data_system.magic_number
# Write each type of game object
Marshal.dump($game_system, export)
Marshal.dump($game_actors, export)
Marshal.dump($game_party, export)
Marshal.dump($game_player, export)
 end
end

 

Scene_Import

#==============================================================================
# ** Scene_Import
#------------------------------------------------------------------------------
#  This class performs Import screen processing.
#==============================================================================

class Scene_Import < Scene_ExportFile
 #--------------------------------------------------------------------------
 # * Object Initialization
 #--------------------------------------------------------------------------
 def initialize
# Remake temporary object
$game_temp = Game_Temp.new
# Timestamp selects new file
$game_temp.last_file_index = 0
for i in 0..3
  exportname = make_exportname(i)
  if FileTest.exist?(exportname)
	export = File.open(exportname, "r")
	export.close
  end
end
super("Which file would you like to import?")
 end
 #--------------------------------------------------------------------------
 # * Decision Processing
 #--------------------------------------------------------------------------
 def on_decision(exportname)
# If file doesn't exist
unless FileTest.exist?(exportname)
  # Play buzzer SE
  $game_system.se_play($data_system.buzzer_se)
  return
end
# Play load SE
$game_system.se_play($data_system.load_se)
# Read save data
export = File.open(exportname, "rb")
read_save_data(export)
export.close
end
 #--------------------------------------------------------------------------
 # * Cancel Processing
 #--------------------------------------------------------------------------
 def on_cancel
# Play cancel SE
$game_system.se_play($data_system.cancel_se)
# Switch to title screen
$scene = Scene_Title.new
 end
 #--------------------------------------------------------------------------
 # * Read Save Data
 #	 file : file object for reading (opened)
 #--------------------------------------------------------------------------
 def read_save_data(export)
# Read character data for drawing save file
characters = Marshal.load(export)
# Read each type of game object  
$game_variables	 = Game_Variables.new  
$game_temp		  = Game_Temp.new
$game_system		= Marshal.load(export)
$game_switches	  = Game_Switches.new
$game_self_switches = Game_SelfSwitches.new
$game_screen		= Game_Screen.new
$game_actors		= Marshal.load(export)
$game_party		 = Marshal.load(export)
$game_troop		 = Game_Troop.new
$game_map		   = Game_Map.new
$game_player		= Marshal.load(export)
#$game_party.setup_starting_members # Uncomment if you don't want the game to start off with all of the characters in the party.
$game_map.setup($data_system.start_map_id)
$game_player.moveto($data_system.start_x, $data_system.start_y)
$game_player.refresh
$game_map.autoplay
$scene = Scene_Map.new
$game_system.bgm_play($game_system.playing_bgm)
$game_system.bgs_play($game_system.playing_bgs)
$game_map.update
 end
end

 

 

To use this code, simply call

$scene = Scene_Export.new

This will allow you to export your file. From there, copy the export (E#.export) into the next game, and then import via load screen. By removing the "New Game" option, you could also force your players to play the first game, then move onto the second game with the exported characters (though I wouldn't do that). Also, the Databases MUST BE THE SAME FOR BOTH GAMES. Meaning you will need to copy the characters, items, classes, etc from the database of the first game into the database of the second game. If you change one thing, IT WILL CHANGE IN THE IMPORT AS WELL. This is due to the fact that it saves numbers, not names and such. So if item number 2 is a High Potion in game one, and item number 2 is an elixir in game 2, the character will import with an elixir. Keep this in mind while making your sequels.

 

Also, go here for a demo. http://www.rmxpunlimited.net/forums/index....mp;showfile=148

 

Give credit to me for this script if you use it. Also, if you find this script on ANY OTHER WEBSITES let me know. This is to be posted here and ONLY HERE on RMXP Unlimited. Thank you.

Share this post


Link to post
Share on other sites

So it's kind of like the PS2 game .Hack//G.U. in a way. You can use the same saved game file from the last game for the new sequal/part, cool.

Share this post


Link to post
Share on other sites

Yeah, although I designed it more after the Quest for Glory export-import system. That was a 5 game series, and you carried your game through every game if you wanted, or created a new character for each game. Although, if you want to get REALLY OLD games involved. The system is designed more off of the old system used in the AD&D Seven Blades Series: Pool of Radiance, Curse of the Azure Bonds, Secret of the Silver Blades, and Pools of Darkness. The same system was then used in the Krynn series: Champions of Krynn, Death Knights of Krynn, Dark Queen of Krynn. Along with the Savage Frontier series: Gateway to the Savage Frontier, Treasures of the Savage Frontier (I think those are right)

Share this post


Link to post
Share on other sites

Never heard of those games before, I'll have to look them up when I can. I got a little lost as to which game you put the scripts in. Which ones are for Game 1 and then for the sequal Game 2.

Share this post


Link to post
Share on other sites

Game 1 will need everything but the import and Scene_Title edit (since there is no game to import to). Game 2 will need all 4 scripts plus the Scene_Title edit. This is so you can import in game 2, then export to game 3 if desired. If there is no game 3, then you COULD remove the export script, but it would probably be good to keep it in, in case you decide to do a game 3 afterwards...like what QFG did. They made 5 games, then still allowed you to export from game 5, but then decided not to do a game 6.

Share this post


Link to post
Share on other sites

Very nice, I played the demo and loved!

But not quite understand what this script does, he is a kind of game save?

Or it allows export graphics from other games?

 

Sorry, the more I really do not understand ... how much more we must have been hard to create this script, so Congratulations!

Share this post


Link to post
Share on other sites

Well, I have been working on it for a year ^^" But no, this allows you to export the characters from one game to another. Do a New Game, get the level up and the elixers, then do an export, then import your characters. You'll notice you start out at a new game with all of the items and levels you had when you exported. That's the purpose of the script, to allow you to carry your characters from one game to another. Like making a game, then making a sequel with the same characters. That help?

Share this post


Link to post
Share on other sites

Uauuu! Very good!

This script is really incredible, now I understand the purpose of it ^ ^

Great script, congratulations!!

 

flw

Share this post


Link to post
Share on other sites

Golden Sun style, I like it ^_^

 

I may end up splittintg my game up now, making it into a small series and just carrying over the characters. Thanks for the ideas ^_^b

 

Although, I don't quite understand how to make one game import the file of another game. Help?

Share this post


Link to post
Share on other sites

When you run the script and export your characters out, you then have to copy the export file into the next game. From there, you run an import in the next game. That help?

 

Also, as I said earlier, it's supposed to be more "Quest for Glory/AD&D" style...I've never played Golden Sun before.

Share this post


Link to post
Share on other sites
When you run the script and export your characters out, you then have to copy the export file into the next game. From there, you run an import in the next game. That help?

 

Also, as I said earlier, it's supposed to be more "Quest for Glory/AD&D" style...I've never played Golden Sun before.

 

Cheers, that helped alot ^_^

 

I'm definately using this system, full credit of course ^_^b

Share this post


Link to post
Share on other sites

Does this work? THIS WOULD BE SO COOL! (Sorry for all caps) I'll give this a try sometime.

Share this post


Link to post
Share on other sites

Does this work? It should work. I haven't had a glitch reported yet, and I didn't encounter any glitches when looking through it myself either.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...