Chaos Project

Game Development => Sea of Code => Topic started by: GaiaTruce on August 03, 2013, 01:25:56 pm

Title: [C#] How to load .rxdata files?
Post by: GaiaTruce on August 03, 2013, 01: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 ? (http://forum.chaos-project.com/index.php?topic=12679.0) and RMXP Raw Data Reading (http://www.hbgames.org/forums/viewtopic.php?&f=179&t=72745).

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.
Title: Re: [C#] How to load .rxdata files?
Post by: G_G on August 03, 2013, 07:04:25 pm
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.
Title: Re: [C#] How to load .rxdata files?
Post by: GaiaTruce on August 04, 2013, 12: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.
Title: Re: [C#] How to load .rxdata files?
Post by: G_G on August 04, 2013, 12: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
Title: Re: [C#] How to load .rxdata files?
Post by: GaiaTruce on August 04, 2013, 01: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?
Title: Re: [C#] How to load .rxdata files?
Post by: G_G on August 04, 2013, 11:17:24 am
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.
Title: Re: [C#] How to load .rxdata files?
Post by: Blizzard on August 06, 2013, 01: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?
Title: Re: [C#] How to load .rxdata files?
Post by: GaiaTruce on August 11, 2013, 09:36:36 am
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:
Title: Re: [C#] How to load .rxdata files?
Post by: GaiaTruce on August 16, 2013, 07:56:32 am
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.
Title: Re: [C#] How to load .rxdata files?
Post by: Blizzard on August 16, 2013, 09:46:53 am
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?).
Title: Re: [C#] How to load .rxdata files?
Post by: GaiaTruce on August 17, 2013, 09:53:22 am
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]);
Title: Re: [C#] How to load .rxdata files?
Post by: Blizzard on August 17, 2013, 05:49:40 pm
I think that MessageBox.Show() takes 2 arguments. Try this:

MessageBox.Show("", a[1].ToString());
Title: Re: [C#] How to load .rxdata files?
Post by: GaiaTruce on August 18, 2013, 03:02:15 am
Hmm... The error still shows.  :huh: If I could ask, does the console.writeline command automatically convert the variable into string?
Title: Re: [C#] How to load .rxdata files?
Post by: Blizzard on August 18, 2013, 05:25:32 am
I'm not sure, but that was the next thing I was going to ask you to try.

MessageBox.Show("", a[1]);
Title: Re: [C#] How to load .rxdata files?
Post by: GaiaTruce on August 18, 2013, 07:00:01 am
Doesn't work again...  :^_^': I read about an issue of IronRuby in this address : http://ironruby.codeplex.com/workitem/4132 (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
Title: Re: [C#] How to load .rxdata files?
Post by: Blizzard on August 18, 2013, 07:21:15 am
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.
Title: Re: [C#] How to load .rxdata files?
Post by: GaiaTruce on August 20, 2013, 07:58:43 am
 :^_^': 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?
Title: Re: [C#] How to load .rxdata files?
Post by: Blizzard on August 20, 2013, 08:21:10 am
I'm not sure what the escape character for " is when you use @ strings. Try using \ instead of ", basically \" instead of "".