Author Topic: Save System Script  (Read 6337 times)

0 Members and 1 Guest are viewing this topic.

Merlandese

  • 静態の遊子
  • *
  • Tier 7
  • **
  • Posts: 5095
  • Gender: Male
  • ---
  • Current Mood: happy happy
Save System Script
« on: October 16, 2011, 12:20:39 PM »
I'm looking for a script of some sort that alters the save and load screens to, basically, anything other than the default one (RMXP). I found a cool-looking script on one of the RM scripters' sites, but I think my account either got tossed (inactivity), or I just can't figure out the password. So I couldn't download any scripts. I think the script I was looking at was by Law, but I wouldn't mind checking out others if anyone has them.

Thanks, guys!

EDIT: Damn. I forgot to put this in Help & Support...
« Last Edit: October 17, 2011, 01:26:27 AM by Merlandese »

Sarkilas

  • *
  • Tier 6
  • **
  • Posts: 429
  • Gender: Male
  • That guy
  • Current Mood: creative creative
Re: Save System Script
« Reply #1 on: October 16, 2011, 12:35:12 PM »
This one is different and shows a thumbnail of the map where you saved on the game with. Alas it is shown without events and without fogs and tints, so sometimes it's kind of annoying :P but it's more detailed than the default and allows a lot more files.

Code: [Select]
#==============================================================================
# ■ ASM - advanced save menu
#------------------------------------------------------------------------------
# by squall // squall@loeher.zzn.com
# monday the 28th of november 2005
#
# Allows to have up to 12 files.
# Files are stored inside of the folder 'Saves' inside of the game's folder.
# Don't forget to create that folder if it doesn't already exist.
#==============================================================================

#==============================================================================
# ■ Window_File
#------------------------------------------------------------------------------
#  This window shows a list of recorded save files.
#==============================================================================

class Window_File < Window_Selectable
#--------------------------------------------------------------------------
# ● initialize
#--------------------------------------------------------------------------
def initialize()
super(0, 64, 320, 416)
self.contents = Bitmap.new(width - 32, 12 * 32)
index = $game_temp.last_file_index == nil ? 0 : $game_temp.last_file_index
self.index = index
@item_max = 12
refresh
end
#--------------------------------------------------------------------------
# ● refresh the window
#--------------------------------------------------------------------------
def refresh
time_stamp = Time.at(0)
for i in 0...12
  filename = "Saves/Save#{i + 1}.rxdata"
self.contents.draw_text(1, i * 32, 32, 32, (i + 1).to_s, 1)
if FileTest.exist?(filename)
size = File.size(filename)
if size.between?(1000, 999999)
size /= 1000
size_str = "#{size} Kb"
elsif size > 999999
size /= 1000000
size_str = "#{size} Mb"
else
size_str = size.to_s
end
time_stamp = File.open(filename, "r").mtime
date = time_stamp.strftime("%d/%m/%Y")
time = time_stamp.strftime("%H:%M")
self.contents.draw_text(38, i * 32, 120, 32, date)
self.contents.draw_text(160, i * 32, 100, 32, time)
self.contents.draw_text(0, i * 32, 284, 32, size_str, 2)
end
end
end
end

#==============================================================================
# ■ Window_FileStatus
#------------------------------------------------------------------------------
#  This window shows the status of the currently selected save file
#==============================================================================

class Window_FileStatus < Window_Base
#--------------------------------------------------------------------------
# ● initialize
#--------------------------------------------------------------------------
def initialize(save_window)
super(320, 64, 320, 416)
self.contents = Bitmap.new(width - 32, height - 32)
@save_window = save_window
@index = @save_window.index
rect = Rect.new(x + 16, y + (height - 32) / 2 + 16, width - 32, (height - 32) / 2)
@viewport = Viewport.new(rect)
@viewport.z = z + 10
refresh
end
#--------------------------------------------------------------------------
# ● dispose the map and the window
#--------------------------------------------------------------------------
def dispose
tilemap_dispose
@viewport.dispose
super
end
#--------------------------------------------------------------------------
# ● refresh the window
#--------------------------------------------------------------------------
def refresh
self.contents.clear
tilemap_dispose
filename = "Saves/Save#{@index + 1}.rxdata"
return unless FileTest.exist?(filename)
file = File.open(filename, "r")
Marshal.load(file)
frame_count = Marshal.load(file)
game=Marshal.load(file)
party = game.party
map = game.map
for i in 0...party.actors.size
actor = party.actors[i]
x = i % 2 * 144 + 4
y = i / 2 * 64
draw_actor_name(actor, x + 40, y)
draw_actor_level(actor, x + 40, y + 32)
draw_actor_graphic(actor, x + 10, y + 50)
end
total_sec = frame_count / Graphics.frame_rate
hour = total_sec / 60 / 60
min = total_sec / 60 % 60
sec = total_sec % 60
text = sprintf("%02d:%02d:%02d", hour, min, sec)
map_name = load_data("Data/MapInfos.rxdata")[map.map_id].name
self.contents.font.color = system_color
self.contents.draw_text(4, 128, 120, 32, "Time Played")
self.contents.draw_text(4, 160, 120, 32, "Location ")
self.contents.draw_text(128, 128, 16, 32, ":")
self.contents.draw_text(128, 160, 16, 32, ":")
self.contents.font.color = normal_color
self.contents.draw_text(144, 128, 120, 32, text)
self.contents.draw_text(144, 160, 120, 32, map_name)

@tilemap = Tilemap.new(@viewport)
@tilemap.tileset = RPG::Cache.tileset(map.tileset_name)
for i in 0..6
autotile_name = map.autotile_names[i]
@tilemap.autotiles[i] = RPG::Cache.autotile(autotile_name)
end
@tilemap.map_data = map.data
@tilemap.ox = map.display_x / 4 + 176
@tilemap.oy = map.display_y / 4 + 148
end
#--------------------------------------------------------------------------
# ● tilemap_dispose
#--------------------------------------------------------------------------
def tilemap_dispose
unless @tilemap == nil
@tilemap.tileset.dispose
for i in 0..6
@tilemap.autotiles[i].dispose
end
@tilemap.dispose
@tilemap = nil
end
end
#--------------------------------------------------------------------------
# ● update
#--------------------------------------------------------------------------
def update
@tilemap.update if @tilemap != nil
if @index != @save_window.index
@index = @save_window.index
refresh
end
super
end
end

#==============================================================================
# ■ Scene_File
#------------------------------------------------------------------------------
#  Base scene for load and save menus.
#==============================================================================

class Scene_File
#--------------------------------------------------------------------------
# ● initialize the scene
#--------------------------------------------------------------------------
def initialize(help_text)
@help_text = help_text
end
#--------------------------------------------------------------------------
# ● main
#--------------------------------------------------------------------------
def main
@help_window = Window_Help.new
@help_window.set_text(@help_text)
@file_window = Window_File.new
@status_window = Window_FileStatus.new(@file_window)
Graphics.transition
loop do
Graphics.update
Input.update
update
if $scene != self
break
end
end
Graphics.freeze
@help_window.dispose
@file_window.dispose
@status_window.dispose
end
#--------------------------------------------------------------------------
# ● update
#--------------------------------------------------------------------------
def update
@help_window.update
@file_window.update
@status_window.update
if Input.trigger?(Input::C)
decision
$game_temp.last_file_index = @file_index
return
end
if Input.trigger?(Input::B)
cancel
return
end
end
#--------------------------------------------------------------------------
# ● return the selected file's name
#--------------------------------------------------------------------------
def filename
return "Saves/Save#{@file_window.index + 1}.rxdata"
end
end

#==============================================================================
# ■ Scene_Save
#------------------------------------------------------------------------------
#  Save menu
#==============================================================================

class Scene_Save < Scene_File
#--------------------------------------------------------------------------
# ● initialize the save menu
#--------------------------------------------------------------------------
def initialize
super("Select a file to record your progress.")
end
#--------------------------------------------------------------------------
# ● decision key pressed
#--------------------------------------------------------------------------
def decision
$game_system.se_play($data_system.save_se)
file = File.open(filename, "wb")
write_save_data(file)
file.close
if $game_temp.save_calling
$game_temp.save_calling = false
$scene = Scene_Map.new
return
end
$scene = Scene_Menu.new(4)
end
#--------------------------------------------------------------------------
# ● cancel key pressed
#--------------------------------------------------------------------------
def cancel
$game_system.se_play($data_system.cancel_se)
if $game_temp.save_calling
$game_temp.save_calling = false
$scene = Scene_Map.new
return
end
$scene = Scene_Menu.new(4)
end
#--------------------------------------------------------------------------
# ● save the current data into the selected file
#--------------------------------------------------------------------------
def write_save_data(file)
characters = []
for i in 0...$game_party.actors.size
actor = $game_party.actors[i]
characters.push([actor.character_name, actor.character_hue])
end
Marshal.dump(characters, file)
Marshal.dump(Graphics.frame_count, file)
$game_system.save_count += 1
$game_system.magic_number = $data_system.magic_number
Marshal.dump($game, file)
end
end

#==============================================================================
# ■ Scene_Load
#------------------------------------------------------------------------------
#  Load menu
#==============================================================================

class Scene_Load < Scene_File
#--------------------------------------------------------------------------
# ● initialize the menu
#--------------------------------------------------------------------------
def initialize
$game_temp_set
$game_temp.last_file_index = 0
latest_time = Time.at(0)
for i in 0..12
filename = "Saves/Save#{i + 1}.rxdata"
if FileTest.exist?(filename)
file = File.open(filename, "r")
if file.mtime > latest_time
latest_time = file.mtime
$game_temp.last_file_index = i
end
file.close
end
end
super("Select a file to load.")
end
#--------------------------------------------------------------------------
# ● decision key pressed
#--------------------------------------------------------------------------
def decision
unless FileTest.exist?(filename)
$game_system.se_play($data_system.buzzer_se)
return
end
$game_system.se_play($data_system.load_se)
file = File.open(filename, "rb")
read_save_data(file)
file.close
$game_system.bgm_play($game_system.playing_bgm)
$game_system.bgs_play($game_system.playing_bgs)
$game_map.update
$scene = Scene_Map.new
end
#--------------------------------------------------------------------------
# ● cancel key pressed
#--------------------------------------------------------------------------
def cancel
$game_system.se_play($data_system.cancel_se)
$scene = Scene_Title.new
end
#--------------------------------------------------------------------------
# ● load the selected file
#--------------------------------------------------------------------------
def read_save_data(file)
characters = Marshal.load(file)
Graphics.frame_count = Marshal.load(file)
$game = Marshal.load(file)
if $game_system.magic_number != $data_system.magic_number
$game_map.setup($game_map.map_id)
$game_player.center($game_player.x, $game_player.y)
end
$game_party.refresh
end
end
It's the only one I have laying around, I think >_o

Need scripting help? Toss me a PM and I'll see what I can do.
Also able to help with anything RMXP related. Please do not hesitate to ask.

Merlandese

  • 静態の遊子
  • *
  • Tier 7
  • **
  • Posts: 5095
  • Gender: Male
  • ---
  • Current Mood: happy happy
Re: Save System Script
« Reply #2 on: October 16, 2011, 12:40:25 PM »
Do I replace a script with this, or do I make a new script above Main?

Sarkilas

  • *
  • Tier 6
  • **
  • Posts: 429
  • Gender: Male
  • That guy
  • Current Mood: creative creative
Re: Save System Script
« Reply #3 on: October 16, 2011, 12:47:53 PM »
Just place it above main. It overrides the default.

Need scripting help? Toss me a PM and I'll see what I can do.
Also able to help with anything RMXP related. Please do not hesitate to ask.

Merlandese

  • 静態の遊子
  • *
  • Tier 7
  • **
  • Posts: 5095
  • Gender: Male
  • ---
  • Current Mood: happy happy
Re: Save System Script
« Reply #4 on: October 16, 2011, 12:57:38 PM »
Ah, thank you, sir. I placed it above Main but below some others and it had zero effect. I moved it up a little and now it works. Hopefully this'll be a good, non-issue script. As always, thank you very much, Sark! :)

Merlandese

  • 静態の遊子
  • *
  • Tier 7
  • **
  • Posts: 5095
  • Gender: Male
  • ---
  • Current Mood: happy happy
Re: Save System Script
« Reply #5 on: October 16, 2011, 01:17:48 PM »
Lines 100 and up give me issues. When I scroll over a previously saved file, it says that there's an undefined method "party". It'll do that for "map" as well.

Sarkilas

  • *
  • Tier 6
  • **
  • Posts: 429
  • Gender: Male
  • That guy
  • Current Mood: creative creative
Re: Save System Script
« Reply #6 on: October 16, 2011, 02:44:31 PM »
Just remove the whole methods "read_save_data()" and "write_save_data()" and it should use the default ones. They load a "$game" object which doesn't exist if you don't use the new data structure.

Need scripting help? Toss me a PM and I'll see what I can do.
Also able to help with anything RMXP related. Please do not hesitate to ask.

Merlandese

  • 静態の遊子
  • *
  • Tier 7
  • **
  • Posts: 5095
  • Gender: Male
  • ---
  • Current Mood: happy happy
Re: Save System Script
« Reply #7 on: October 16, 2011, 05:01:05 PM »
Just remove the whole methods "read_save_data()" and "write_save_data()" and it should use the default ones. They load a "$game" object which doesn't exist if you don't use the new data structure.

I did a ctrl+f search through the script and deleted both of those (two of each), but wound up with more and more issues. Most of them being that it can't define words like "party," "map," "character," etc. I think whatever issue it's having is the sections that transfer data to the picture, but I'm not positive.

I went on a happy-delete-button spree and just kept erasing every line it told me was wrong after tossing those first methods (:)). But it didn't work.

Sarkilas

  • *
  • Tier 6
  • **
  • Posts: 429
  • Gender: Male
  • That guy
  • Current Mood: creative creative
Re: Save System Script
« Reply #8 on: October 16, 2011, 05:06:43 PM »
No it's because it tries to load "$game", which does not exist with the default engine. What this object contains is all the default classes into one object (eg. $game.party, $game.map instead of $game_party and $game_map as separate objects). That is why this issue occurs, but I don't see where these things even occur, I fixed all the parts to use "$game_" instead of "$game.", so it doesn't even show up. I mean, "$game.party" isn't in the script at all, so I don't get why it tries to access this unavailable object for no apparent reason. I'm too tired to look into it. I don't have the original, only the modification to work with the Game:Class, which you don't use and would require a complete rewrite of all your scripts.

EDIT: Problem found. It lies in the "refresh" method where you find "game.map" and "game.party". This is the incorrect data structure. I'm too tired to solve it for you, but basically you need to get the original loading structures and make sure you load those two objects from the save file selected and obtain them under the same variables. In addition, as said, the loading and saving methods as mentioned before needs to match the saving and loading structure of the default. You find these by doing Ctrl+Shift+F and searching for "write_save_data" and "read_save_data" and checking the default scripts. Just follow those leads.
« Last Edit: October 16, 2011, 05:10:32 PM by Sarkilas »

Need scripting help? Toss me a PM and I'll see what I can do.
Also able to help with anything RMXP related. Please do not hesitate to ask.

Merlandese

  • 静態の遊子
  • *
  • Tier 7
  • **
  • Posts: 5095
  • Gender: Male
  • ---
  • Current Mood: happy happy
Re: Save System Script
« Reply #9 on: October 16, 2011, 05:15:36 PM »
Thanks, Sark! Get some rest. I'll see if I can't fix this. :)

EDIT: I think this' been handled... for now... bum bum BUM!

I'll lock it off.
« Last Edit: October 17, 2011, 01:26:08 AM by Merlandese »