Hi.
I'm not quite sure where to post this (feel free to move it around if you like) or if there's any interest at all. But I think it's quite neat so here I am.
I've written a little utility in Ruby that can convert between SVG files and the XML format Planeshift uses to export sketches / user drawn maps.
The direction Sketch -> SVG is pretty trivial and lossless, however the other way round isn't. In fact my tool ignores mostly everything in the SVG file - except things Planeshift understands. And by "understands", I mean: can also be achieved through the in-game editor. I don't know if that's the same. Anyway, here an example:
For those of you who know Ruby (I'ld think most of you do
), there's also the (fully documented) PlaneShiftSketchXML class which allows you to easily modify the XML files yourself. Example (from the documentation):
require 'planeshift_sketch_xml'
Dir.foreach('~/.PlaneShift/sketches') do |name|
sketch = PlaneShiftSketchXML.load_from(name)
sketch.add_text(sketch.width - 300, sketch.height - 50, 'signature')
sketch.save_to(name)
end
This would add a signature to all of your saved sketches... I know, somewhat limited example, just to show how simple it is.
Main drawback of converting SVG files to sketches is the 200 elements limit Planeshift sets on the imported sketches. On the other hand, if this limit wasn't there I wouldn't have released this, because who knows what noob would spam the server with Megabytes of XML...
To run the thing, you need to have Ruby 1.8 installed, either through your distribution's package system (Linux) or as a download package from
here. Simply open a console window, navigate to the folder you've extracted the zip file to, and type 'ruby svg2sketchxml.rb' or 'ruby sketchxml2svg.rb', without the quotes, appending the name of the source and dest files. For example:
ruby svg2sketchxml mymap.svg mymap.xml
You can then copy the mymap.xml file into the sketches subfolder of your PS settings directory and import it from within the game.
[Under Linux, you can alternatively run './<script>.rb' instead of 'ruby <script>.rb']
Feel free to report any bug, but please don't ask about how to get ruby running here or how to code in it... this is not the place for it.
I hope some of you find it useful. Here's the download:
PlaneShift Sketch XML API, SVG converters and documentationPlease read the text file in the icons subdirectory if you can't see any icons in SVG files converted from sketches. AFAIK, PS license forbids me to bundle those icons with the zip, thus I've written a description where to find them.