Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- =begin
- - Global Variables
- - Made by: Sixth
- A pretty simple script which will make the specified variables global ones, so
- they will share the same value across all play-throughs.
- Setup the filename and initial data for the variables in the script.
- Note that only the specified variables in the @data settings will be set to
- global, the rest of them will operate normally.
- You can check and edit these global variables the same way like any others.
- Be aware that constantly updating these variables might cause performance loss
- depending on the amount and data types of your global variables, and it is not
- a good idea to constantly write data onto the HDD in general.
- Use these variables with this in mind!
- =end
- module GlobVars
- # Setup the file path and name here.
- # It can NOT be in an encrypted folder!
- FName = "System/MyFile.rvdata2"
- def self.load_vars
- begin
- @data = load_data(FName)
- rescue
- # Setup the initial data for the global variables here.
- # Format: variable_id => value,
- @data = {
- 10 => 15,
- 13 => 'somedata2',
- 24 => [],
- # And so on...
- }
- # Settings end here!
- save_vars
- end
- end
- def self.save_vars
- save_data(@data,FName)
- end
- def self.data
- return @data
- end
- load_vars
- end
- class << DataManager
- alias load_glob_vars6241 extract_save_contents
- def extract_save_contents(contents)
- load_glob_vars6241(contents)
- $game_variables.load_glob_vars
- end
- end
- class Game_Variables
- alias load_glob_vars8266 initialize
- def initialize
- load_glob_vars8266
- load_glob_vars
- end
- def load_glob_vars
- GlobVars.data.each {|vid,val| @data[vid] = val }
- end
- alias save_glob_vars8882 []=
- def []=(vid, val)
- save_glob_vars8882(vid, val)
- if GlobVars.data[vid]
- GlobVars.data[vid] = @data[vid]
- GlobVars.save_vars
- end
- end
- end
- # End of script! O.o
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement