Script 'Persistent Data' - error with Debug Menu

Status
Not open for further replies.

ZirconStorms

VX & VX Ace Scripts
Veteran
Joined
Dec 22, 2014
Messages
359
Reaction score
113
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
39,367
Reaction score
12,871
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
30,261
Reaction score
7,138
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

VX & VX Ace Scripts
Veteran
Joined
Dec 22, 2014
Messages
359
Reaction score
113
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

VX & VX Ace Scripts
Veteran
Joined
Dec 22, 2014
Messages
359
Reaction score
113
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
39,367
Reaction score
12,871
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

VX & VX Ace Scripts
Veteran
Joined
Dec 22, 2014
Messages
359
Reaction score
113
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,003
Reaction score
11,324
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

A group of Game creators and others who trying to revive the Feel of Multiplayer and TOWN/ROLEPLAY games
Wow, lots of RPG Maker MV stuff on sale on Steam for 50%-75% off. Steam, why you not tell me?!
looking for help on top secret project
The nick "Toeuia" that I'm using comes from a, idk, you okay the chess game while chit chatting them. The first two are students. Then you know, finally, the champion, and then the champion's sensei. I played like this so many times until suddenly there's another chess master. Very naive but super smart. After he lost, he kinda advised me not to give up on chest. Because the next one was never seen beaten. Touya.
I'm currently playing Ara Fell - I can see why it's had generally good reviews. The exploration aspect is pretty strong and the writing is passable.

The game auto-saves and offers an option to turn back just before each major combat, and immediately brings the player back to the last position saved when there's a TPK. Convenient at the very least.

Forum statistics

Threads
99,379
Messages
964,632
Members
130,997
Latest member
thaydoidiachicongty
Top