Author Topic: [C#] How to load .rxdata files?  (Read 8863 times)

Offline GaiaTruce

  • Total Beginner
  • Posts: 9
  • LV: 0
    • View Profile
[C#] How to load .rxdata files?
« on: August 03, 2013, 07:25:56 PM »
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.

Offline G_G

  • Green Gmod Game_Guy AKA G4 AKA hyper-G AKA G-force
  • Global Moderator
  • Chaos Ultimate
  • ****
  • Posts: 6585
  • LV: 407
  • Gender: Male
    • View Profile
Re: [C#] How to load .rxdata files?
« Reply #1 on: August 04, 2013, 01:04:25 AM »
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.

Offline GaiaTruce

  • Total Beginner
  • Posts: 9
  • LV: 0
    • View Profile
Re: [C#] How to load .rxdata files?
« Reply #2 on: August 04, 2013, 06:11:51 AM »
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.

Offline G_G

  • Green Gmod Game_Guy AKA G4 AKA hyper-G AKA G-force
  • Global Moderator
  • Chaos Ultimate
  • ****
  • Posts: 6585
  • LV: 407
  • Gender: Male
    • View Profile
Re: [C#] How to load .rxdata files?
« Reply #3 on: August 04, 2013, 06:37:20 AM »
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

Offline GaiaTruce

  • Total Beginner
  • Posts: 9
  • LV: 0
    • View Profile
Re: [C#] How to load .rxdata files?
« Reply #4 on: August 04, 2013, 07:02:42 AM »
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?

Offline G_G

  • Green Gmod Game_Guy AKA G4 AKA hyper-G AKA G-force
  • Global Moderator
  • Chaos Ultimate
  • ****
  • Posts: 6585
  • LV: 407
  • Gender: Male
    • View Profile
Re: [C#] How to load .rxdata files?
« Reply #5 on: August 04, 2013, 05:17:24 PM »
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.

Offline Blizzard

  • This sexy
  • Administrator
  • has over 9000 posts
  • *****
  • Posts: 19981
  • LV: 647
  • Gender: Male
  • Magic midgets.
    • View Profile
    • You're already on it. (-_-')
Re: [C#] How to load .rxdata files?
« Reply #6 on: August 06, 2013, 07:49:53 PM »
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      King of Booze: Never Ever      Pet Bots
Drinking Game for Android      Never have I ever for Android      Pet Bots for Android
Drinking Game for iOS      Never have I ever for iOS      Pet Bots for iOS
Drinking Game on Steam


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

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

Offline GaiaTruce

  • Total Beginner
  • Posts: 9
  • LV: 0
    • View Profile
Re: [C#] How to load .rxdata files?
« Reply #7 on: August 11, 2013, 03:36:36 PM »
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:

Offline GaiaTruce

  • Total Beginner
  • Posts: 9
  • LV: 0
    • View Profile
Re: [C#] How to load .rxdata files?
« Reply #8 on: August 16, 2013, 01:56:32 PM »
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.

Offline Blizzard

  • This sexy
  • Administrator
  • has over 9000 posts
  • *****
  • Posts: 19981
  • LV: 647
  • Gender: Male
  • Magic midgets.
    • View Profile
    • You're already on it. (-_-')
Re: [C#] How to load .rxdata files?
« Reply #9 on: August 16, 2013, 03:46:53 PM »
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      King of Booze: Never Ever      Pet Bots
Drinking Game for Android      Never have I ever for Android      Pet Bots for Android
Drinking Game for iOS      Never have I ever for iOS      Pet Bots for iOS
Drinking Game on Steam


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

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

Offline GaiaTruce

  • Total Beginner
  • Posts: 9
  • LV: 0
    • View Profile
Re: [C#] How to load .rxdata files?
« Reply #10 on: August 17, 2013, 03:53:22 PM »
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 :
Code: [Select]
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 :
Code: [Select]
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]);
« Last Edit: August 17, 2013, 03:58:53 PM by GaiaTruce »

Offline Blizzard

  • This sexy
  • Administrator
  • has over 9000 posts
  • *****
  • Posts: 19981
  • LV: 647
  • Gender: Male
  • Magic midgets.
    • View Profile
    • You're already on it. (-_-')
Re: [C#] How to load .rxdata files?
« Reply #11 on: August 17, 2013, 11:49:40 PM »
I think that MessageBox.Show() takes 2 arguments. Try this:

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

King of Booze      King of Booze: Never Ever      Pet Bots
Drinking Game for Android      Never have I ever for Android      Pet Bots for Android
Drinking Game for iOS      Never have I ever for iOS      Pet Bots for iOS
Drinking Game on Steam


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

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

Offline GaiaTruce

  • Total Beginner
  • Posts: 9
  • LV: 0
    • View Profile
Re: [C#] How to load .rxdata files?
« Reply #12 on: August 18, 2013, 09:02:15 AM »
Hmm... The error still shows.  :huh: If I could ask, does the console.writeline command automatically convert the variable into string?

Offline Blizzard

  • This sexy
  • Administrator
  • has over 9000 posts
  • *****
  • Posts: 19981
  • LV: 647
  • Gender: Male
  • Magic midgets.
    • View Profile
    • You're already on it. (-_-')
Re: [C#] How to load .rxdata files?
« Reply #13 on: August 18, 2013, 11:25:32 AM »
I'm not sure, but that was the next thing I was going to ask you to try.

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

King of Booze      King of Booze: Never Ever      Pet Bots
Drinking Game for Android      Never have I ever for Android      Pet Bots for Android
Drinking Game for iOS      Never have I ever for iOS      Pet Bots for iOS
Drinking Game on Steam


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

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

Offline GaiaTruce

  • Total Beginner
  • Posts: 9
  • LV: 0
    • View Profile
Re: [C#] How to load .rxdata files?
« Reply #14 on: August 18, 2013, 01:00:01 PM »
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

Offline Blizzard

  • This sexy
  • Administrator
  • has over 9000 posts
  • *****
  • Posts: 19981
  • LV: 647
  • Gender: Male
  • Magic midgets.
    • View Profile
    • You're already on it. (-_-')
Re: [C#] How to load .rxdata files?
« Reply #15 on: August 18, 2013, 01:21:15 PM »
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      King of Booze: Never Ever      Pet Bots
Drinking Game for Android      Never have I ever for Android      Pet Bots for Android
Drinking Game for iOS      Never have I ever for iOS      Pet Bots for iOS
Drinking Game on Steam


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

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

Offline GaiaTruce

  • Total Beginner
  • Posts: 9
  • LV: 0
    • View Profile
Re: [C#] How to load .rxdata files?
« Reply #16 on: August 20, 2013, 01:58:43 PM »
 :^_^': 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 :
Code: [Select]
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?
« Last Edit: August 20, 2013, 02:13:48 PM by GaiaTruce »

Offline Blizzard

  • This sexy
  • Administrator
  • has over 9000 posts
  • *****
  • Posts: 19981
  • LV: 647
  • Gender: Male
  • Magic midgets.
    • View Profile
    • You're already on it. (-_-')
Re: [C#] How to load .rxdata files?
« Reply #17 on: August 20, 2013, 02:21:10 PM »
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      King of Booze: Never Ever      Pet Bots
Drinking Game for Android      Never have I ever for Android      Pet Bots for Android
Drinking Game for iOS      Never have I ever for iOS      Pet Bots for iOS
Drinking Game on Steam


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

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