Save Extender and Save Deletion "Hard Mode V1.0"

Description:

This script does 2 things:

1. This script acts as a save extender and can change the number of saves the player is allowed to have. 

2. This script also acts as a save file exterminator upon Game Over of the players currently loaded or currently saved file. Using the save/load index.

Script:

Terms of Use:

This script can be use in both commercial and non-commercial games.
Credit to Goldstorm

Special thanks to Nio and Galenmereth

First time really trying something like this so I would really like some constructive criticism on this script if anyone is willing to give it. It started off as kind of a joke, but then evolved into something eventually. I'll be fine tuning the script over time. If you want to use it/edit it for your own game or enjoyment, PM me, email me, carrier pigeon me, and go for it. 🙂
Criticism inbound... (whether you use it constructively or not is your own choice) 🙂

There is no need for creating the global variable '$globalindexplus'  It barely does anything and could easily be changed for a regular instance variable.

Instead of doing this..

      if @indexplus >= 10 #Checks the index of saving if it's above/below 10        #msgbox_p("We're Over 10 boys!") #For Troubleshooting purposes        $globalstring = "Save#{@indexplus}.rvdata2"      else        #msgbox_p("We're Under 10 boys!") #For Troubleshooting purposes        $globalstring = "Save0#{@indexplus}.rvdata2"      endyou could do this...

$globalstring = "Save#{"%02d" % @indexplus}.rvdata2"But again, the use of a global variable is pointless.

there is also no need to overwrite the methods as you have done. They could very easily be aliased to provide similar results.

Actually, I've rewrote your script (sorry)... Here is the changes i made..

Spoiler
module DataManager # DataManager::Gold.module module GOLD NUMBER_OF_SAVES = 100 HARD_MODE = true end # Begin DataManager.methods class << self # Public instance variable for DataManager.globalstring attr_reader :globalstring # New Game Method alias :newaliasforsetup_new_game :setup_new_game def setup_new_game newaliasforsetup_new_game @globalstring = nil end # Load game method alias :newaliasforload_game_without_rescue :load_game_without_rescue def load_game_without_rescue(index) # Calls alias method data. loaded = true if successful. loaded = newaliasforload_game_without_rescue(index) @globalstring = "Save#{"%02d" % (index+1)}.rvdata2" if loaded end # Save Game method alias :newaliasforsave_game_without_rescue :save_game_without_rescue def save_game_without_rescue(index) # Calls alias method data. saved = true if successful. saved = newaliasforsave_game_without_rescue(index) @globalstring = "Save#{"%02d" % (index+1)}.rvdata2" if saved end # Savefile method def savefile_max return GOLD::NUMBER_OF_SAVES end end # End Module Methodsend # End Moduleclass Game_Interpreter alias :newaliasforcommand_353 :command_353 def command_353 if DataManager.save_file_exists? if DataManager::GOLD::HARD_MODE name = DataManager.globalstring File.delete(name) if name end end newaliasforcommand_353 end end
feel free to implement the changes i have highlighted into your version of the script. 🙂

If you have any questions on why i done what i done, feel free to ask.

Also ~ Nice to see you finally scripting ^_^
Thank you for taking the time to do this Dekita. Have a few questions for you though.

Question 1:

Spoiler
The following 2 methods you made for saving and loading (newaliasforload_game_without_rescue and newaliasforsave_game_without_rescue). There is the keyword alias, what is the difference between alias and alias_method, and am I correct in assuming that the new methods you made that I stated above are inheriting the data from the default VX Ace methods?

# Load game method alias :newaliasforload_game_without_rescue :load_game_without_rescue def load_game_without_rescue(index) # Calls alias method data. loaded = true if successful. loaded = newaliasforload_game_without_rescue(index) @instancestring = "Save#{"%02d" % (index+1)}.rvdata2" if loaded end # Save Game method alias :newaliasforsave_game_without_rescue :save_game_without_rescue def save_game_without_rescue(index) # Calls alias method data. saved = true if successful. saved = newaliasforsave_game_without_rescue(index) @instancestring = "Save#{"%02d" % (index+1)}.rvdata2" if saved endI understand what happens within those methods, thanks for explaining that on the side. 🙂
Question 2:

Spoiler
Ok, really 3 questions. The class << self line. From the tutorials I've read, class is a class and when followed by << self that means it's inheriting the methods from the self class (oh god I hope that makes sense). Why is this one named this way (is this just something you've made for this particular tutorial or is it something else)? How does it differentiate from what I tried and probably botched explaining above? The third question I have is regarding the attr_reader line. This is just a way to pass instanced variables between classes? If so, this is why I couldn't get it working before.

Code:
  class << self    # Public instance variable for DataManager.instancestring    attr_reader :instancestring
1 - There really isn't much of a difference, and its certainly not worth worrying about when you are just starting to learn. Ether will work just as well. 🙂

The reason i use alias is simply because it has syntax highlighting and is faster to write. 😛

2 - Sigh...

Try and take what information you can from this. It might be a little much...

This is code that wont work...

module MyModule def self.mymethod # Does Cool Stuff end # This CLASS variable wont work (its a module). attr_reader :myvariable # The below code will certainly cause an error as cannot alias a module method. alias :new_mymethod :mymethod def self.mymethod new_mymethod # Add New Cool Stuff endendputs MyModule.myvariable # Will cause an error as no method.variable defined of this name. Code that works:

module MyModule # opens 'metaclass' of MyModule (dont worry about it too much) class << self # Notice, method does not have 'self.' before it, there is no need. # All method defined within the 'class << self' section are considered # instance methods of the MyModule class. def mymethod # Does Cool Stuff end # This CLASS variable WILL work (its NOT a module). attr_reader :myvariable # This alias code will work, as its aliasing the method defined in the # metaclass of MyModule. alias :new_mymethod :mymethod def mymethod new_mymethod # Calls alias method # Add New Cool Stuff end endendputs MyModule.myvariable # Will print nil until it has been defined in some methodIn short, in order to alias a module's .self type method, you have to alias the method within a class << self ; ; end block.  Also, for attr_reader and accessor, gotta define them in the metclass of the module. 🙂

NOTE :: This would also work...

module MyModule # Open metaclass to alias the method. class << self alias :new_mymethod :mymethod end def self.mymethod new_mymethod # Calls alias method # Add New Cool Stuff endend3 - The reason you couldnt get the attr_reader to work in the module is because it was not defined within the metaclass of the module. The above code has more information on that kinda thing 🙂

Let me know if there is any other queries you have 🙂

Original thread: https://forums.rpgmakerweb.com/threads/save-extender-and-save-deletion-hard-mode-v1-0.36701/