[C#] How to load .rxdata files?

Started by GaiaTruce, August 03, 2013, 01:25:56 pm

Previous topic - Next topic

GaiaTruce

First of all, I'm very sorry if my English is very bad. I'm not a native speaker and obviously English isn't my native tongue.

Maybe this topic is frequently discussed here. I found same topics all around the place while searching. Like this : How can I create a form in Windows7 to manage Object of RGSS ? and RMXP Raw Data Reading.

Well, like those topics, I want to know how to load .rxdata files that are created by RMXP. The reason is I want to create a program that add many features to RMXP but I can't do that if I can't open the rxdata files.

I've tried to use IronRuby v. 1.0 and 1.1.3 but neither of them works. I use .NET Framework 4.0 and Visual C# 2010 Express.

Whenever I try to use the IronRuby v.1.0, I keep getting errors that I think have something to do with Microsoft.Scripting.Core. But when I use IronRuby v.1.1.3,  C# keeps saying "Method not implemented.". I think it means that I call a method that hasn't been defined. The error shows up when I use ExecuteFile command to open Ruby(.rb) file that contains methods and class that are used by the .rxdata (Table, Color, Tone, and RPG Module Class). In the official website, there is someone who reports the same error.

If someone can give me the source code of the program that can open rxdata, I will be very grateful. But if you can't, just tell me what I have to do or at least the basic concept. Please keep in mind that I just started programming in C# 1 year ago. So maybe I can't understand some terms.

G_G

You need to implement Table, Color, Tone, and RPG Module data yourself. You need to put all of those classes into a ruby script file, then load the file first.

Either that or you can write your own custom reader and writer. You just have to know how Ruby serialization works. Blizzard created his own Ruby data reader in his Blizz-ABS Config tool. Maybe you can look at the source code there.

GaiaTruce

Wow... Thanks for your reply gameus(or I think game_guy?). Yeah, I've tried it. Whenever I want to load the file that contains all the class (Table, Color, Tone, and RPG Module), the Method not implemented error shows up. I still don't know which version of IronRuby I should use. Because both of them seems to have issues either with the framework or the method.

G_G

You want to use IronRuby 1.0. You have to make sure the Table, Tone, Color, etc.. classes are above the RPG Modules I think. I'll try to find my source code for my Price editor

GaiaTruce

Like I said, everytime I want to use the IronRuby v.1.0, I keep getting Microsoft.Scripting.Core errors. I think I once read that Microsoft merge the Microsoft.Scripting.Core with other dlls when they updated the Framework into 4.0. So the IronRuby tried to find Microsoft.Scripting.Core but there's no such file in the system.

I really appreciate it if you want to share the source code. I forgot to tell you that I have checked the Blizz-ABS Config program. Yes, it can read rxdata files. But it only reads rxdata files that have ids and names.(Weapon, Armor, Actor, MapInfos) What about the others like System.rxdata?

G_G

Look at how the Blizz-ABS config does it. It reads the file in binary format. If anything, try using .NET framework 3.5 or 2.0. And if you need to, import Microsoft.Scripting.Core into your project.

Blizzard

The Blizz-ABS Config app doesn't implement a full reader, though. It only implements enough to be able to read entry names and they are for C# objects, not Ruby objects. As gameus said, you need the Ruby implementations for these 4 extra classes.

Ryex, can you dig out the Ruby implementations we use for ARC?
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

GaiaTruce

I'm sorry if I was late to reply. Thanks for your replies, Blizzard & gameus.  :^_^': While browsing another forum, I stumbled upon a program that uses IronRuby. It seems that the main problem is that the version of IronRuby that I used is incompatible with the .NET Framework. When I try to use the IronRuby dlls that were placed on the program, it works.  :???:

Sorry for all the troubles...  :facepalm:

GaiaTruce

Now another problem arises... When I try to load the .rxdata that i've just created, C# keeps saying "Object reference not set to an instance of an object.".

This problem seems to show only if I use the Windows Form Application. When I try it in a Console Application, it works. I saved the data in a hash.

The error suggests that the object I call is null / nil. But when I try it with the console, it produces the value.

Blizzard

This usually happens when a variable has not been set yet. If there is a problem with one type of app, but not the other, it's possible that some forms control wasn't set or created yet or that there is something that is used in one type, but not the other. You should get the line where it breaks if you run it in debug. It's most likely that just an object wasn't created (maybe there is no "new Hash<K, V>()" call?).
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

GaiaTruce

August 17, 2013, 09:53:22 am #10 Last Edit: August 17, 2013, 09:58:53 am by GaiaTruce
I'm sure I wrote the same code with the one that I wrote in the console application.

Here is the code in the form application :
ScriptRuntime runtime = Ruby.CreateRuntime();
ScriptEngine engine = Ruby.GetEngine(runtime);
engine.ExecuteFile("class.rb");
object asdf = engine.Execute(@"f = File.open('Notetag.rxdata', 'rb')
m = Marshal.load(f)
return m[""Items""]");
RubyArray a = (RubyArray)asdf;
MessageBox.Show(a[1].ToString());


And here is the one in the console application :
ScriptRuntime runtime = Ruby.CreateRuntime();
ScriptEngine engine = Ruby.GetEngine(runtime);
engine.ExecuteFile("class.rb");
object asdf = engine.Execute(@"f = File.open('Notetag.rxdata', 'rb')
m = Marshal.load(f)
return m[""Items""]");
RubyArray a = (RubyArray)asdf;
Console.WriteLine(a[1]);

Blizzard

I think that MessageBox.Show() takes 2 arguments. Try this:

MessageBox.Show("", a[1].ToString());
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

GaiaTruce

Hmm... The error still shows.  :huh: If I could ask, does the console.writeline command automatically convert the variable into string?

Blizzard

I'm not sure, but that was the next thing I was going to ask you to try.

MessageBox.Show("", a[1]);
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

GaiaTruce

Doesn't work again...  :^_^': I read about an issue of IronRuby in this address : http://ironruby.codeplex.com/workitem/4132 I don't know if it is the issue or not. Oh yeah, I want to ask about ARC. Does it use IronRuby or another implementation?  Sorry if it's bothering you. :P

Blizzard

ARC basically uses the official Ruby release. It does use a certain revision of the SVN trunk instead of an actual public release due to some problems, but it still uses the official one.
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

GaiaTruce

August 20, 2013, 07:58:43 am #16 Last Edit: August 20, 2013, 08:13:48 am by GaiaTruce
 :^_^': Sorry for the late reply again... Anyway, do you know what's wrong with the code?  :???:

I think it has something to do with this line :
return m[""Items""]")
Is this the correct way to get a value from a hash where the key is a string? Should I add another code to make into string?  :huh: Or should I escape the " character? If I should, how can I do it?

Blizzard

I'm not sure what the escape character for " is when you use @ strings. Try using \ instead of ", basically \" instead of "".
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.