Script 'Persistent Data' - error with Debug Menu

Status
Not open for further replies.

ZirconStorms

Veteran
Veteran
Joined
Dec 22, 2014
Messages
359
Reaction score
111
First Language
English
Primarily Uses
RMVXA
The only available versions I see of the script is through these two links - the script author is Fomar0153:
  1. https://aveyond.com/forums/index.php?/topic/15048-need-helpexplanation-with-this-script/
  2. https://steamcommunity.com/sharedfiles/filedetails/?l=english&id=230899119
Error description: It seems that the game bugs when trying to scroll through the variable section of the debug menu. Putting the number of switches above 100 causes this error pop up:
upload_2018-9-30_22-33-16.png
If you put your switch limit to 111 or anything that's less than 200, this happens:
upload_2018-9-30_22-33-59.png
Demo attached below. Here are the areas I think are causing the issue:
upload_2018-9-30_22-26-47.png
In the Persistent Data script (specifically the $game_persistentvariables)
upload_2018-9-30_22-27-46.png
In Window_DebugLeft.
 

Attachments

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
It just wasn't written with the debug window in mind, expecting only switches/variables that exist to be referenced.

Try replacing it with this:
Code:
=begin
Persistent Data
by Fomar0153
Version 1.0
----------------------
Notes
----------------------
Allows you to preserve the values of selected variables
and switches across all games.
----------------------
Instructions
----------------------
If you wish adjust the strings in the Fomar module.
Then put the PERSISTENT_DATA_STRING in to the names of
the switches or variables that are to be persistent.
E.g.
[p]Talked to mayor
Case 1: Progress [p]
----------------------
Known bugs
----------------------
None
=end

module Fomar

 # Enter the string below into the names of the switches or variables
 # that are to be persistent
 PERSISTENT_DATA_STRING = "[p]"
 # DO NOT USE SAVE in the string below
 PFILENAME = "PersistentData.rvdata2"

end

class Game_PersistentSwitches
 #--------------------------------------------------------------------------
 # * Object Initialization
 #--------------------------------------------------------------------------
 def initialize
   @data = {}
 end
 #--------------------------------------------------------------------------
 # * Get Switch
 #--------------------------------------------------------------------------
 def [](switch_id)
   @data[switch_id] || false
 end
 #--------------------------------------------------------------------------
 # * Set Switch
 #     value : ON (true) / OFF (false)
 #--------------------------------------------------------------------------
 def []=(switch_id, value)
   @data[switch_id] = value
   DataManager.save_persistent
 end
end

class Game_PersistentVariables
 #--------------------------------------------------------------------------
 # * Object Initialization
 #--------------------------------------------------------------------------
 def initialize
   @data = {}
 end
 #--------------------------------------------------------------------------
 # * Get Variable
 #--------------------------------------------------------------------------
 def [](variable_id)
   @data[variable_id] || 0
 end
 #--------------------------------------------------------------------------
 # * Set Variable
 #--------------------------------------------------------------------------
 def []=(variable_id, value)
   @data[variable_id] = value
   DataManager.save_persistent
 end
end

class Game_Switches
 #--------------------------------------------------------------------------
 # * Get Switch
 #--------------------------------------------------------------------------
 def [](switch_id)
   if $data_system.switches[switch_id] && $data_system.switches[switch_id].include?(Fomar::PERSISTENT_DATA_STRING)
     return $game_persistentswitches[switch_id]
   else
     return @data[switch_id] || false
   end
 end
 #--------------------------------------------------------------------------
 # * Set Switch
 #     value : ON (true) / OFF (false)
 #--------------------------------------------------------------------------
 def []=(switch_id, value)
   if $data_system.switches[switch_id] && $data_system.switches[switch_id].include?(Fomar::PERSISTENT_DATA_STRING)
     $game_persistentswitches[switch_id] = value
   else
     @data[switch_id] = value
   end
   on_change
 end
end

class Game_Variables
 #--------------------------------------------------------------------------
 # * Get Variable
 #--------------------------------------------------------------------------
 def [](variable_id)
   if $data_system.variables[variable_id] && $data_system.variables[variable_id].include?(Fomar::PERSISTENT_DATA_STRING)
     return $game_persistentvariables[variable_id]
   else
     return @data[variable_id] || 0
   end
 end
 #--------------------------------------------------------------------------
 # * Set Variable
 #--------------------------------------------------------------------------
 def []=(variable_id, value)
   if $data_system.variables[variable_id] && $data_system.variables[variable_id].include?(Fomar::PERSISTENT_DATA_STRING)
     $game_persistentvariables[variable_id] = value
   else
     @data[variable_id] = value
   end
   on_change
 end
end

module DataManager
 #--------------------------------------------------------------------------
 # * Aliases
 #--------------------------------------------------------------------------
 class << self
   alias persistent_create_game_objects create_game_objects
   alias persistent_load_game load_game
 end
 #--------------------------------------------------------------------------
 # * Execute Load
 #--------------------------------------------------------------------------
 def self.load_game(index)
   self.load_persistent
   return self.persistent_load_game(index)
 end
 #--------------------------------------------------------------------------
 # * Create Game Objects
 #--------------------------------------------------------------------------
 def self.create_game_objects
   self.persistent_create_game_objects
   self.load_persistent
 end
 #--------------------------------------------------------------------------
 # * Save Persistent Data
 #--------------------------------------------------------------------------
 def self.save_persistent
   begin
     File.open(Fomar::PFILENAME, "wb") do |file|
       persistent = {}
       persistent[:switches] = $game_persistentswitches
       persistent[:variables] = $game_persistentvariables
       Marshal.dump(persistent, file)
     end
   rescue
     File.delete(Fomar::PFILENAME) rescue nil
   end
 end
 #--------------------------------------------------------------------------
 # * Load Persistent Data
 #--------------------------------------------------------------------------
 def self.load_persistent
   begin
     File.open(Fomar::PFILENAME, "rb") do |file|
       contents = Marshal.load(file)
       $game_persistentswitches  = contents[:switches]
       $game_persistentvariables = contents[:variables]
     end
   rescue
     $game_persistentswitches  = Game_PersistentSwitches.new
     $game_persistentvariables = Game_PersistentVariables.new
     self.save_persistent
   end
 end
end
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
31,355
Reaction score
7,668
First Language
German
Primarily Uses
RMMV
please make sure that your script slots are correctly named.
having one of the slots still with the name "insert here" is bad for later bughunting.
Please give every slot a name that tells which script is there
 

ZirconStorms

Veteran
Veteran
Joined
Dec 22, 2014
Messages
359
Reaction score
111
First Language
English
Primarily Uses
RMVXA
please make sure that your script slots are correctly named.
having one of the slots still with the name "insert here" is bad for later bughunting.
Please give every slot a name that tells which script is there
You really have a problem with me, huh.
For the sake of a demo with only *one* third party script, this is a non-issue.
 

ZirconStorms

Veteran
Veteran
Joined
Dec 22, 2014
Messages
359
Reaction score
111
First Language
English
Primarily Uses
RMVXA
It just wasn't written with the debug window in mind, expecting only switches/variables that exist to be referenced.

Try replacing it with this:
Code:
=begin
Persistent Data
by Fomar0153
Version 1.0
----------------------
Notes
----------------------
Allows you to preserve the values of selected variables
and switches across all games.
----------------------
Instructions
----------------------
If you wish adjust the strings in the Fomar module.
Then put the PERSISTENT_DATA_STRING in to the names of
the switches or variables that are to be persistent.
E.g.
[p]Talked to mayor
Case 1: Progress [p]
----------------------
Known bugs
----------------------
None
=end

module Fomar

 # Enter the string below into the names of the switches or variables
 # that are to be persistent
 PERSISTENT_DATA_STRING = "[p]"
 # DO NOT USE SAVE in the string below
 PFILENAME = "PersistentData.rvdata2"

end

class Game_PersistentSwitches
 #--------------------------------------------------------------------------
 # * Object Initialization
 #--------------------------------------------------------------------------
 def initialize
   @data = {}
 end
 #--------------------------------------------------------------------------
 # * Get Switch
 #--------------------------------------------------------------------------
 def [](switch_id)
   @data[switch_id] || false
 end
 #--------------------------------------------------------------------------
 # * Set Switch
 #     value : ON (true) / OFF (false)
 #--------------------------------------------------------------------------
 def []=(switch_id, value)
   @data[switch_id] = value
   DataManager.save_persistent
 end
end

class Game_PersistentVariables
 #--------------------------------------------------------------------------
 # * Object Initialization
 #--------------------------------------------------------------------------
 def initialize
   @data = {}
 end
 #--------------------------------------------------------------------------
 # * Get Variable
 #--------------------------------------------------------------------------
 def [](variable_id)
   @data[variable_id] || 0
 end
 #--------------------------------------------------------------------------
 # * Set Variable
 #--------------------------------------------------------------------------
 def []=(variable_id, value)
   @data[variable_id] = value
   DataManager.save_persistent
 end
end

class Game_Switches
 #--------------------------------------------------------------------------
 # * Get Switch
 #--------------------------------------------------------------------------
 def [](switch_id)
   if $data_system.switches[switch_id] && $data_system.switches[switch_id].include?(Fomar::PERSISTENT_DATA_STRING)
     return $game_persistentswitches[switch_id]
   else
     return @data[switch_id] || false
   end
 end
 #--------------------------------------------------------------------------
 # * Set Switch
 #     value : ON (true) / OFF (false)
 #--------------------------------------------------------------------------
 def []=(switch_id, value)
   if $data_system.switches[switch_id] && $data_system.switches[switch_id].include?(Fomar::PERSISTENT_DATA_STRING)
     $game_persistentswitches[switch_id] = value
   else
     @data[switch_id] = value
   end
   on_change
 end
end

class Game_Variables
 #--------------------------------------------------------------------------
 # * Get Variable
 #--------------------------------------------------------------------------
 def [](variable_id)
   if $data_system.variables[variable_id] && $data_system.variables[variable_id].include?(Fomar::PERSISTENT_DATA_STRING)
     return $game_persistentvariables[variable_id]
   else
     return @data[variable_id] || 0
   end
 end
 #--------------------------------------------------------------------------
 # * Set Variable
 #--------------------------------------------------------------------------
 def []=(variable_id, value)
   if $data_system.variables[variable_id] && $data_system.variables[variable_id].include?(Fomar::PERSISTENT_DATA_STRING)
     $game_persistentvariables[variable_id] = value
   else
     @data[variable_id] = value
   end
   on_change
 end
end

module DataManager
 #--------------------------------------------------------------------------
 # * Aliases
 #--------------------------------------------------------------------------
 class << self
   alias persistent_create_game_objects create_game_objects
   alias persistent_load_game load_game
 end
 #--------------------------------------------------------------------------
 # * Execute Load
 #--------------------------------------------------------------------------
 def self.load_game(index)
   self.load_persistent
   return self.persistent_load_game(index)
 end
 #--------------------------------------------------------------------------
 # * Create Game Objects
 #--------------------------------------------------------------------------
 def self.create_game_objects
   self.persistent_create_game_objects
   self.load_persistent
 end
 #--------------------------------------------------------------------------
 # * Save Persistent Data
 #--------------------------------------------------------------------------
 def self.save_persistent
   begin
     File.open(Fomar::PFILENAME, "wb") do |file|
       persistent = {}
       persistent[:switches] = $game_persistentswitches
       persistent[:variables] = $game_persistentvariables
       Marshal.dump(persistent, file)
     end
   rescue
     File.delete(Fomar::PFILENAME) rescue nil
   end
 end
 #--------------------------------------------------------------------------
 # * Load Persistent Data
 #--------------------------------------------------------------------------
 def self.load_persistent
   begin
     File.open(Fomar::PFILENAME, "rb") do |file|
       contents = Marshal.load(file)
       $game_persistentswitches  = contents[:switches]
       $game_persistentvariables = contents[:variables]
     end
   rescue
     $game_persistentswitches  = Game_PersistentSwitches.new
     $game_persistentvariables = Game_PersistentVariables.new
     self.save_persistent
   end
 end
end
Solves the issue perfectly. Thank you.
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
For the sake of a demo with only *one* third party script, this is a non-issue
Actually, it's not. I opened your demo and I couldn't find the script. I wondered if you hadn't put it in and was going to come back and ask you to upload it again with the script. It was only by accident that I looked in that particular slot and found it.
 

ZirconStorms

Veteran
Veteran
Joined
Dec 22, 2014
Messages
359
Reaction score
111
First Language
English
Primarily Uses
RMVXA
Actually, it's not. I opened your demo and I couldn't find the script. I wondered if you hadn't put it in and was going to come back and ask you to upload it again with the script. It was only by accident that I looked in that particular slot and found it.
Fair enough, alright. I'll keep it in mind for future script questions.
 

Kes

Veteran
Veteran
Joined
Aug 3, 2012
Messages
22,299
Reaction score
11,712
First Language
English
Primarily Uses
RMVXA
[closed]IgnoreMe[/closed]
 
Status
Not open for further replies.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

How many parameters is 'too many'??
Yay, now back in action Happy Christmas time, coming back!






Back in action to develop the indie game that has been long overdue... Final Fallacy. A game that keeps on giving! The development never ends as the developer thinks to be the smart cookie by coming back and beginning by saying... "Oh bother, this indie game has been long overdue..." How could one resist such? No-one c
So I was playing with filters and this looked interesting...

Versus the normal look...

Kind of gives a very different feel. :LZSexcite:
To whom ever person or persons who re-did the DS/DS+ asset packs for MV (as in, they are all 48x48, and not just x2 the pixel scale) .... THANK-YOU!!!!!!!!! XwwwwX

Forum statistics

Threads
105,849
Messages
1,016,981
Members
137,563
Latest member
cexojow
Top