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.

unlimited save file help!!

Jking

Member

ok so i ran across this script for unlimited saves, well there are some errors it has. its gotten to the point were i have absolutely no clue how to fix it.

here it is
Paste this in a new script right above main...
Code:
class Scene_File
  SAVEFILE_MAX = 99
# -------------------
def initialize(help_text)
  @help_text = help_text
end
# -------------------
def main
  @help_window = Window_Help.new
  @help_window.set_text(@help_text)
  @savefile_windows = []
  @cursor_displace = 0
  for i in 0..3
    @savefile_windows.push(Window_SaveFile.new(i, make_filename(i), i))
  end
  @file_index = 0
  @savefile_windows[@file_index].selected = true
  Graphics.transition
  loop do
    Graphics.update
    Input.update
    update
    if $scene != self
      break
    end
  end
  Graphics.freeze
  @help_window.dispose
  for i in @savefile_windows
    i.dispose
  end
end
# -------------------
def update
  @help_window.update
  for i in @savefile_windows
    i.update
  end
  if Input.trigger?(Input::C)
    on_decision(make_filename(@file_index))
    $game_temp.last_file_index = @file_index
    return
  end
  if Input.trigger?(Input::B)
    on_cancel
    return
  end
  if Input.repeat?(Input::DOWN)
    if Input.trigger?(Input::DOWN) or @file_index < SAVEFILE_MAX - 1
      if @file_index == SAVEFILE_MAX - 1
        $game_system.se_play($data_system.buzzer_se)
        return
      end
      @cursor_displace += 1
      if @cursor_displace == 4
        @cursor_displace = 3
        for i in @savefile_windows
          i.dispose
        end
        @savefile_windows = []
        for i in 0..3
          f = i - 2 + @file_index
          name = make_filename(f)
          @savefile_windows.push(Window_SaveFile.new(f, name, i))
          @savefile_windows[i].selected = false
        end
      end
      $game_system.se_play($data_system.cursor_se)
      @file_index = (@file_index + 1)
      if @file_index == SAVEFILE_MAX
        @file_index = SAVEFILE_MAX - 1
      end
      for i in 0..3
        @savefile_windows[i].selected = false
      end
      @savefile_windows[@cursor_displace].selected = true
      return
    end
  end
  if Input.repeat?(Input::UP)
    if Input.trigger?(Input::UP) or @file_index > 0
      if @file_index == 0
        $game_system.se_play($data_system.buzzer_se)
        return
      end
      @cursor_displace -= 1
      if @cursor_displace == -1
        @cursor_displace = 0
        for i in @savefile_windows
          i.dispose
        end
        @savefile_windows = []
        for i in 0..3
          f = i - 1 + @file_index
          name = make_filename(f)
          @savefile_windows.push(Window_SaveFile.new(f, name, i))
          @savefile_windows[i].selected = false
        end
      end
      $game_system.se_play($data_system.cursor_se)
      @file_index = (@file_index - 1)
      if @file_index == -1
        @file_index = 0
      end
      for i in 0..3
        @savefile_windows[i].selected = false
      end
      @savefile_windows[@cursor_displace].selected = true
      return
    end
  end
end
# -------------------
def make_filename(file_index)
  return "Save#{file_index + 1}.rxdata"
end
# -------------------
end

Paste this in the same script, or another script below the previous one...
Code:
class Window_SaveFile < Window_Base
# -------------------
def initialize(file_index, filename, position)
  y = 64 + position * 104
  super(0, y, 640, 104)
  self.contents = Bitmap.new(width - 32, height - 32)
  @file_index = file_index
  @filename = "Save#{@file_index + 1}.rxdata"
  @time_stamp = Time.at(0)
  @file_exist = FileTest.exist?(@filename)
  if @file_exist
    file = File.open(@filename, "r")
    @time_stamp = file.mtime
    @characters = Marshal.load(file)
    @frame_count = Marshal.load(file)
    @game_system = Marshal.load(file)
    @game_switches = Marshal.load(file)
    @game_variables = Marshal.load(file)
    @total_sec = @frame_count / Graphics.frame_rate
    file.close
  end
  refresh
  @selected = false
end
end
the problem is,

Script 'window_SaveFile' line 22: NameError occured.

undefined local variable or method `refresh` for #<window_SaveFile:0x159e498>

it doesnt say that till you try to save.
 
The line that's giving you trouble there is...
Code:
Replace WINDOW_SAVEFILE with this...

Since that script only redefines the 'initialize' method, you should paste it in a new script above main,
and not replace the original Window_Savefile script.

Be Well

Code:
You're also missing some [i] array indexes in the code you posted.
Make sure you put code in [ code ][ /code ] tags.
 

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