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.

A save script

Okay, so I know that there is probibly one on this site, but for the life of me I can't seem to find it.

I need a script that ASKS the player if they wish to DELETE by saving over old data and if they want to CONFIRM a save before the data is SAVED.

Now, if I need to explain more, then I will.

I want it to look something like this:

asking for data override for existing data
ASKINGTODELETEOLDDATA.jpg


asking to save on an empty file
ASKINGTOSAVE.jpg
 
Here you go. It's a script that asks "Are you sure", but you can edit it to say something different. Credit goes to SS Muu.

Code:
#==============================================================================

# ** Decision

#------------------------------------------------------------------------------

# Author    S.S Muu

# Version   1.0

# Date      01-07-09 (dd-mm-yy)

#==============================================================================

 

class Decision < Window_Base

  #--------------------------------------------------------------------------

  # * Object Initialization

  #--------------------------------------------------------------------------

  def initialize

    super(220, 150, 200, 110)

    self.contents = Bitmap.new(width - 32, height - 32)

    self.z = 10000

  end

  #--------------------------------------------------------------------------

  # * Start

  #--------------------------------------------------------------------------

  def start

    self.active = true

    @yes = false

    @ret = false

    refresh

    main_loop

    # Return with the decision

    return @yes

  end

  #--------------------------------------------------------------------------

  # * Main Loop

  #--------------------------------------------------------------------------

  def main_loop    

    # Execute transition

    Graphics.transition

    # Main loop

    loop do

      # Update game screen

      Graphics.update

      # Update input information

      Input.update

      # Frame update

      update

      # Abort loop if a decision has been made

      if @ret

        break

      end

    end

    # Prepare for transition

    Graphics.freeze

    # Dispose of windows

    self.dispose

    # Execute transition

    Graphics.transition

    # Update game screen

    Graphics.update

  end

  #--------------------------------------------------------------------------

  # * Update

  #--------------------------------------------------------------------------

  def update

    super

    # If the right or left directional button was pressed

    if Input.repeat?(Input::RIGHT) or Input.repeat?(Input::LEFT)

      move_cursor

    end

    # If the C button was pressed

    if Input.trigger?(Input::C)

      case @yes

      when true

        $game_system.se_play($data_system.decision_se)

      when false

        $game_system.se_play($data_system.cancel_se)

      end

      @ret = true

    end

  end

  #--------------------------------------------------------------------------

  # * Refresh

  #--------------------------------------------------------------------------

  def refresh

    self.contents.clear

    self.contents.draw_text(0, 0, 168, 40, "Are you sure?", 1)

    self.contents.draw_text(0, 40, 168, 40, "Yes      No", 1)

    self.cursor_rect.set(95, 45, 48, 32)

  end

  #--------------------------------------------------------------------------

  # * Move Cursor

  #--------------------------------------------------------------------------

  def move_cursor

    $game_system.se_play($data_system.cursor_se)

    @yes = !@yes

    if @yes

      self.cursor_rect.set(30, 45, 48, 32)

    else

      self.cursor_rect.set(95, 45, 48, 32)

    end

  end

end

 

 

#==============================================================================

# ** Scene_Save

#------------------------------------------------------------------------------

#  This class performs save screen processing.

#==============================================================================

 

class Scene_Save < Scene_File

  #--------------------------------------------------------------------------

  # * Decision Processing

  #--------------------------------------------------------------------------

  def on_decision(filename)

    # Play save SE

    $game_system.se_play($data_system.save_se)

    # Display decision window

    dec = Decision.new

    # Save if "Yes" was chosen

    if dec.start

      # Write save data

      file = File.open(filename, "wb")

      write_save_data(file)

      file.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_Map.new

        return

      end

      # Switch to menu screen

      $scene = Scene_Menu.new(4)

    end

  end

end

 

 
 
For some reason, there is a syntax error in line 2.
I at first put the new save script above main, and I had this error, so I replaced the Scene_Save script with the new save script and I still got the same error. Can someone help again? Sorry! I am a total klutz with scripts. >.<
 

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