I have an interesting problem here.
Some of you might know of this error when you want to open your project and RMXP pops up an error saying "Can't read data", which often means your data is corrupted or something like that.
Well, I have this problem. But in my case, I know exactly what's causing it but I don't know how to fix it.
I am adding new variables and child classes to the RPG::Class class. It now looks something like that:
[ruby]
module RPG
class Class
attr_accessor :battle_commands
# Aliasing the initialize method seems useless since RMXP overwrites everything when you save
alias my_new_rpg_class initialize initialize
def initialize
my_new_rpg_class initialize
@battle_commands = [RPG::Class::BattleCommand.new]
end
# Created a new method to make sure my new variable is initialized
def init_var
@battle_commands = [RPG::Class::BattleCommand.new]
end
# New child class
class BattleCommand
# my stuff here...
end
end
end
[/ruby]
I then run a small script in game to save the data with my own new stuff like that:
[ruby]
for classes in $data_classes.compact
classes.init_var
end
save_data($data_classes, "Data/Classes.rxdata")
[/ruby]
Up to now, everything seems to work fine. But, when I close RMXP (without saving because it would overwrite the changes I made to the Classes data), and I reopen it, I get the error.
"Can't read classes data."
It's obvious that the problem is caused by the modifications I made. But the strange thing is that I tried that with more than half of the other RPG Data (actor, troop, enemy, etc.) and it worked very well. Only RPG::Class gives me trouble like that. I also tried to do that externally, with a little program I made using wxRuby but the results are the same.
Any idea on what's going on?
EDIT:
I tried to put integers and string into my @battle_commands array and it worked. SO it must be related to my new child class. I tried to make a new independent class with it but I still get the error.
Thanks in advance
-Dargor
Some of you might know of this error when you want to open your project and RMXP pops up an error saying "Can't read data", which often means your data is corrupted or something like that.
Well, I have this problem. But in my case, I know exactly what's causing it but I don't know how to fix it.
I am adding new variables and child classes to the RPG::Class class. It now looks something like that:
[ruby]
module RPG
class Class
attr_accessor :battle_commands
# Aliasing the initialize method seems useless since RMXP overwrites everything when you save
alias my_new_rpg_class initialize initialize
def initialize
my_new_rpg_class initialize
@battle_commands = [RPG::Class::BattleCommand.new]
end
# Created a new method to make sure my new variable is initialized
def init_var
@battle_commands = [RPG::Class::BattleCommand.new]
end
# New child class
class BattleCommand
# my stuff here...
end
end
end
[/ruby]
I then run a small script in game to save the data with my own new stuff like that:
[ruby]
for classes in $data_classes.compact
classes.init_var
end
save_data($data_classes, "Data/Classes.rxdata")
[/ruby]
Up to now, everything seems to work fine. But, when I close RMXP (without saving because it would overwrite the changes I made to the Classes data), and I reopen it, I get the error.
"Can't read classes data."
It's obvious that the problem is caused by the modifications I made. But the strange thing is that I tried that with more than half of the other RPG Data (actor, troop, enemy, etc.) and it worked very well. Only RPG::Class gives me trouble like that. I also tried to do that externally, with a little program I made using wxRuby but the results are the same.
Any idea on what's going on?
EDIT:
I tried to put integers and string into my @battle_commands array and it worked. SO it must be related to my new child class. I tried to make a new independent class with it but I still get the error.
Thanks in advance
-Dargor