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.

Custom Autosave.

Hey everyone.

Well let me explain my request.

A script that autosaves when you teleport to a new map BUT ONLY if switch 1 is OFF!

so if switch 1 is on, then it does not autosave when you go to a new map.

:] if you need any more detail please just ask, i appologize if this does not explain well enough.

Please and thanks!

~Saikyo
 
Not sure if it will work, since I didn't test it...try this anyways.

Code:
#==============================================================================
# Autosave Script Offline 1.0
#------------------------------------------------------------------------------
# Authors   Darklord, Blue Elf and Me?
# Version   Offline 1.0
#------------------------------------------------------------------------------
# This script aliases(a)/rewrites(r) in the folowwing classes and methods:
#
#  Game_Party  -> gain_gold  (a) , gain_item (a), gain_armor (a), gain_weapon (a)
#  add_actor (a), remove_actor (a)
#  Game_System -> initialize (a)
#  Scene_Save  -> initialize (a,r) , on_decision (a,r)
#  Scene_Map   -> transfer player (r)
#  Scene_Battle 1 -> battle_end (a)
#==============================================================================


#==============================================================================
# *** AutoSave
#------------------------------------------------------------------------------
# This module handles the AutoSaving
#==============================================================================
module AutoSave
#--------------------------------------------------------------------------
# * Saves File
#--------------------------------------------------------------------------
def self.save
  begin
    #Saves the file to whatever $game_system.filename is
    file = File.open($game_system.filename, "wb")
    a = Scene_Save.new
    a.write_save_data(file)
  ensure
    file.close
  end
end
#--------------------------------------------------------------------------
# * Deletes File
#--------------------------------------------------------------------------
def self.deletesave
  begin
    if FileTest.exits?($game_system.filename)
      File.delete($game_system.filename)
    end  
  end
end
end
#==============================================================================

#==============================================================================
# ** Scene_AutoSave
#------------------------------------------------------------------------------
# This class performs save screen processing.
# This changes the autosave file
#==============================================================================

class Scene_AutoSave < Scene_File
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize
    super("Which file would you like to Autosave to?")
  end
  #--------------------------------------------------------------------------
  # * Decision Processing
  #--------------------------------------------------------------------------
  def on_decision(filename)
    # Play save SE
    $game_system.se_play($data_system.save_se)
    $game_system.filename_c(filename)
    # 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_Map.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_Map.new
      return
    end
    # Switch to menu screen
    $scene = Scene_Map.new
  end
end

#==============================================================================
# ** Game_System
#------------------------------------------------------------------------------
#  This class handles data surrounding the system. Backround music, etc.
#  is managed here as well. Refer to "$game_system" for the instance of
#  this class.
#==============================================================================
class Game_System
#--------------------------------------------------------------------------
# * Aliasing Objects
#--------------------------------------------------------------------------
alias autosaveinit initialize
#--------------------------------------------------------------------------
# * Initialize
#--------------------------------------------------------------------------
def initialize
  autosaveinit
  @filename = "Save1.rxdata"
end
#--------------------------------------------------------------------------
# * Filename -> Returns Autosave Filename
#--------------------------------------------------------------------------
def filename
  if @filename != nil
    return @filename
  else
    return "Save1.rxdata"
  end  
end
#--------------------------------------------------------------------------
# * Filename_change -> Sets New Autosave Filename
#--------------------------------------------------------------------------
def filename_c(newname)
  return if newname == "" or newname == nil
  @filename = newname
end
end

#==============================================================================
# ** Scene_Map
#------------------------------------------------------------------------------
#  This class performs map screen processing.
#==============================================================================

class Scene_Map
alias tp_autosave transfer_player
#--------------------------------------------------------------------------
# * Player Place Move
#--------------------------------------------------------------------------
def transfer_player 
 $game_map.map_id != $game_temp.player_new_map_id ? result = true : result = false 
 tp_autosave
if $game_switches[1] == false 
 AutoSave.save if result
end 
end
end
 
didnt work =[

When the switch is on, and you load the game it still loads up on the screen its not supposed to.

what i need the script for is for my zombie infection system, i wanna make it so it autosaves UNTILL you get bitten, and when the BITTEN switch (switch 1) is ON, then it stops autosaving. So when you load up the game, youll load up the map where before you screwed up and got bitten =]

thanks for trying though
 

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