Project on Github.
If you're interested in the project just let me know.
I came across this XML parsing/generating library when I was looking for pure-ruby implementations of various serializers, and after copying some extra files over and adding a new file, I've got it working in RM.
I haven't extensively tested it, but it seems to be able to parse and generate XML files.
The next step is to provide serialization methods for ruby objects so that we can store our data in XML rather than binary Marshal format.
The goal is to be able to provide XML serialization as an alternative to ruby's Marshal serialization. This way, you can do things like
- share project files through version control systems (though, my understanding is that this can already be done? So I'm not sure if there's any value to text-format in this case)
- modify database files without having to go through Ruby (you can use an external editor, use scripts to generate it, etc)
Sure, everything can be done if you just use Ruby, but the idea is that you shouldn't be restricted to Ruby. Or IronRuby. Or having to find a library for working with ruby's binary serialization.
I saw this http://www.hbgames.org/forums/viewtopic.php?f=155&t=72404, so evidently XML support for RPG Maker has already been done somewhere? If there's already a project for it, I'd like to know.
RMXML - REXML for RPG Maker
● ARCHIVED · READ-ONLY
-
-
For serialization, I like the way Ox does it
http://ohler.com/ox/
They use a generic ruby object serialization approach. so for example, suppose you have the following class definition
module Test class Sample attr_accessor :a, :b, :c def initialize(a, b, c) @a = a @b = b @c = c end endendAnd we create something like this
Code:Ox would create this kind of output# Create two objects, one contained in the otherobj2 = Test::Sample.new(1, "child", ['x', :y, 5.0])obj = Test::Sample.new(1, "parent", obj2)
Code:It can handle most things you throw at it, so I will likely use the same approach.Maybe there's an RM-compatible XML library that can do this already.<o c="Test::Sample"> <i a="@a">1</i> <s a="@b">parent</s> <o a="@c" c="Test::Sample"> <i a="@a">1</i> <s a="@b">child</s> <a a="@c"> <s>x</s> <m>y</m> <f>5</f> </a> </o></o> -
Working version of the parser and generator has been pushed.
Here's a demo showing a couple things.
https://github.com/Hime-Works/RMXML/blob/master/demo.zip
It supports most of the objects that come with standard ruby, as well as Table, Tone, Color, and Rect (since those can be stored in save files).
This is intended to be a dev tool since the format is too obscure for humans to create manually.
The way it's formatted is also kind of funny, but I prioritized proper white-spaces over beauty.
Here's how a Game_Actor object looks
It's too slow for large files atm though. Not sure how to optimize it. Feel free to test it, make it faster, improve it, use it, etc.Spoiler<o c='Game_Actor' id='0'><s a='@battler_name' ></s ><i a='@battler_hue' >0</i ><a a='@actions' /><i a='@speed' >0</i ><o c='Game_ActionResult' id='1' a='@result' ><p a='@battler' >0</p ><n a='@used' /><n a='@missed' /><n a='@evaded' /><n a='@critical' /><n a='@success' /><i a='@hp_damage' >0</i ><i a='@mp_damage' >0</i ><i a='@tp_damage' >0</i ><i a='@hp_drain' >0</i ><i a='@mp_drain' >0</i ><a a='@added_states' /><a a='@removed_states' /><a a='@added_buffs' /><a a='@added_debuffs' /><a a='@removed_buffs' /></o ><i a='@last_target_index' >0</i ><n a='@guarding' /><i a='@animation_id' >0</i ><n a='@animation_mirror' /><z a='@sprite_effect_type' /><i a='@tp' >0</i ><i a='@mp' >41</i ><i a='@hp' >562</i ><n a='@hidden' /><a a='@param_plus' ><i >0</i ><i >0</i ><i >0</i ><i >0</i ><i >0</i ><i >0</i ><i >0</i ><i >0</i ></a ><a a='@states' /><h a='@state_turns' /><h a='@state_steps' /><a a='@buffs' ><i >0</i ><i >0</i ><i >0</i ><i >0</i ><i >0</i ><i >0</i ><i >0</i ><i >0</i ></a ><h a='@buff_turns' /><i a='@actor_id' >1</i ><s a='@name' >Hime</s ><s a='@nickname' >Silver Reaper</s ><s a='@character_name' >Actor5</s ><i a='@character_index' >1</i ><s a='@face_name' >Actor5</s ><i a='@face_index' >1</i ><i a='@class_id' >1</i ><i a='@level' >1</i ><h a='@exp' ><i >1</i ><i >0</i ></h ><a a='@equips' ><o c='Game_BaseItem' id='2' ><o c='Class' id='3' a='@class' /><i a='@item_id' >1</i ></o ><o c='Game_BaseItem' id='4' ><o c='Class' id='5' a='@class' /><i a='@item_id' >46</i ></o ><o c='Game_BaseItem' id='6' ><z a='@class' /><i a='@item_id' >0</i ></o ><o c='Game_BaseItem' id='7' ><p a='@class' >5</p ><i a='@item_id' >1</i ></o ><o c='Game_BaseItem' id='8' ><z a='@class' /><i a='@item_id' >0</i ></o ></a ><a a='@skills' /><i a='@action_input_index' >0</i ><o c='Game_BaseItem' id='9' a='@last_skill' ><z a='@class' /><i a='@item_id' >0</i ></o ></o>