Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: [1] 2

Author Topic: Dwarf Fortress World Information to XML - Now Online, No Download Required  (Read 7630 times)

timmeh

  • Bay Watcher
    • View Profile
    • My Portfolio

I was looking through the Future of the Fortress topic, and was reading this and decided that, instead of bugging Toady to make DF export all the information in XML format, I'd write a simple program to convert the current files to XML format.  There are now two versions available, one as downloadable .exe files (technically .zip), and one in Javascript/HTML, which can be accessed without a download.

Neither version the program (currently) syntax checks the outputted XML.  I advise downloading XML Marker (freeware XML editor) for syntax checking.  If you have any problems with the outputted XML, please let me know, and I'll see about fixing it.

Enjoy!

Download - 547KB

Site and Population Converter
World History Converter
Site and Population Display Example
World History Display Example

Sites and Populations, DF Output
World History, DF Output



Spoiler: Releases (click to show/hide)

Spoiler: Non-release Progress (click to show/hide)
« Last Edit: March 06, 2010, 11:04:52 am by timmeh »
Logged
On the Wall is a Masterfully engraved carving of Urist McHardcastle and Goblins. Urist McHardcastle is surrounded by the Goblins. The Golbins are stamping on Urist McHardcastle. Urist McHardcaste is laughing at the Goblins. The carving related to the prolonged and bloody death of Urist McHardcastle in the Fall of 1659, the Winter of 1659, and the Spring of 1660. On the engraving is an image of Cheese.

timmeh

  • Bay Watcher
    • View Profile
    • My Portfolio
Re: Convert Dwarf Fortress History and World to XML
« Reply #1 on: February 26, 2010, 12:53:22 pm »

New release, see first post.
Logged
On the Wall is a Masterfully engraved carving of Urist McHardcastle and Goblins. Urist McHardcastle is surrounded by the Goblins. The Golbins are stamping on Urist McHardcastle. Urist McHardcaste is laughing at the Goblins. The carving related to the prolonged and bloody death of Urist McHardcastle in the Fall of 1659, the Winter of 1659, and the Spring of 1660. On the engraving is an image of Cheese.

Dohon

  • Bay Watcher
    • View Profile
Re: Convert Dwarf Fortress History and World to XML
« Reply #2 on: February 27, 2010, 10:08:57 am »

You, sir, are a true Dwarf.

Will try this out tonight.
Logged
Quote from: Lolfail0009
Quote from: GuesssWho
Also, why is there a stray hen having a tantrum?
CLUCK CLUCK MOTHERF***ER

timmeh

  • Bay Watcher
    • View Profile
    • My Portfolio
Re: Convert Dwarf Fortress History and World to XML
« Reply #3 on: February 28, 2010, 10:03:35 pm »

Will try this out tonight.

Any luck?  :P
Logged
On the Wall is a Masterfully engraved carving of Urist McHardcastle and Goblins. Urist McHardcastle is surrounded by the Goblins. The Golbins are stamping on Urist McHardcastle. Urist McHardcaste is laughing at the Goblins. The carving related to the prolonged and bloody death of Urist McHardcastle in the Fall of 1659, the Winter of 1659, and the Spring of 1660. On the engraving is an image of Cheese.

timmeh

  • Bay Watcher
    • View Profile
    • My Portfolio
Re: Convert Dwarf Fortress History and World to XML
« Reply #4 on: March 03, 2010, 09:23:31 pm »

Quick question, I've been working with Javascript a lot lately, and it shouldn't be too hard for me to make this a web-app instead, would that be worth my time?  Would anyone use it as such?

Basically, it would require that you copy-paste the text from one of the files into a text-box, and it would output the XML file into another one.  Ought to make this a lot more accessible than the console app, and really all it will require is some syntax changes, and some small changes to the way it loops through the lines of text...
Logged
On the Wall is a Masterfully engraved carving of Urist McHardcastle and Goblins. Urist McHardcastle is surrounded by the Goblins. The Golbins are stamping on Urist McHardcastle. Urist McHardcaste is laughing at the Goblins. The carving related to the prolonged and bloody death of Urist McHardcastle in the Fall of 1659, the Winter of 1659, and the Spring of 1660. On the engraving is an image of Cheese.

Naes Draw

  • Bay Watcher
  • She likes modding for their customizability.
    • View Profile
Re: Convert Dwarf Fortress History and World to XML
« Reply #5 on: March 03, 2010, 09:50:29 pm »

As long as it wasn't too hard to find, that sounds usable.
Logged
[CREATURE:CAT]
   [NAME:sena cat:sena cat:sena cat]
   [INTELLIGENT] [MISCHIEVOUS] [FEMALE]
   [PREFSTRING:craziness]
   [SHOES:ITEM_SHOES_SHOES:UNCOMMON]
   [PERMITTED_JOB:MODDER]

timmeh

  • Bay Watcher
    • View Profile
    • My Portfolio
Re: Convert Dwarf Fortress History and World to XML
« Reply #6 on: March 03, 2010, 10:06:37 pm »

The source would be free, in case something happens to my website, but in the mean time it would reside there, and should be pretty simple, two text areas and a button.

[EDIT]:  I got the converter for the sites and populations file done.  It can be found here.  It's overly simple and rather ugly at the moment, but it functions.  I'm having some trouble with the table output part, since I'm using JQuery now it doesn't want to play nice, so I'm going to rewrite it some time tomorrow.  Then I can write up the world history converter, and see about getting that info displayed. 

And before I forget, using this is incredibly simple.  Just copy the contents of your "regionX-world_sites_and_pops.txt" file into the top text area (after deleting the instruction text), and click the button, the text area below will be filled with the XML.  It's probably a little buggy, so I'll look over it all again tomorrow, but I'm to tired to write anymore coherent code right now...

[EDIT2]:  I got the Site display done, links to both are in the first post.

[EDIT3]:  And a random example DF output, for those who don't care to generate their own for testing purposes: Link
« Last Edit: March 06, 2010, 10:53:39 am by timmeh »
Logged
On the Wall is a Masterfully engraved carving of Urist McHardcastle and Goblins. Urist McHardcastle is surrounded by the Goblins. The Golbins are stamping on Urist McHardcastle. Urist McHardcaste is laughing at the Goblins. The carving related to the prolonged and bloody death of Urist McHardcastle in the Fall of 1659, the Winter of 1659, and the Spring of 1660. On the engraving is an image of Cheese.

timmeh

  • Bay Watcher
    • View Profile
    • My Portfolio

The full program, both for site and population as well as world history, is available online without a download.  See the first post for links to the converters, example display pages (mediocre at best, but it's something) and example DF output files for anyone who doesn't want to generate a new world just to test this.
Logged
On the Wall is a Masterfully engraved carving of Urist McHardcastle and Goblins. Urist McHardcastle is surrounded by the Goblins. The Golbins are stamping on Urist McHardcastle. Urist McHardcaste is laughing at the Goblins. The carving related to the prolonged and bloody death of Urist McHardcastle in the Fall of 1659, the Winter of 1659, and the Spring of 1660. On the engraving is an image of Cheese.

Scarpa

  • Bay Watcher
    • View Profile

This is pretty sweet, I'll keep playing with it and let you know if I run into any issues.
Logged

Hummingbird

  • Bay Watcher
    • View Profile

This is awesome! And thank you for making it available as a webapp; not all of us have PCs.

The World History converter doesn't seem to work, though. And the file it asks me to copy-paste is the same as in the Sites and Pops converter. Neither file showed results when inputted into the history converter.

But this is a great tool you have here. Keep it up, please!
Logged
But Elves aren't Vegetarians. They eat people.
So they are humanitarians.

Kaelem Gaen

  • Bay Watcher
  • And then it appeared the most terrifying creature
    • View Profile

I can't find the region text file, I assume it's what you're supposed to get when you hit the p button after the world gens? (or is it d)?

Nevermind  it was because the feature was broken on d## series, though maybe only d17+  -goes to test- Yep at least it's broken in D17, haven't tried d18 opr D19 2
« Last Edit: March 06, 2010, 05:02:55 pm by Kaelem Gaen »
Logged

timmeh

  • Bay Watcher
    • View Profile
    • My Portfolio

@Scarpa - Thanks, the input is really appreciated!  I love working on stuff like this, but I don't have a whole lot of free time to test it...

@Hummingbird - :D  A point a mac-fan friend of mine has made very apparent to me recently :P  Speaking of which, while it should be cross browser, I make no guarantees for IE... IE has this nasty tendency to require that things be done differently from every other browser, and from the W3 standards...

As far as the world history converter, that was just a typo... the name of the file that's contents should be pasted in there will be something like "region2-world_history.txt" (although the world folder will be where "region2" is).  The example file I posted seems to work, if you have any problems with it just let me know, the file you pasted, and the browser you're using would be awesome too :D

Thanks, will do!  :D

@Kaelem Gaen - The example files were exported via Mike Mayday's package, which I believe is D16.  I haven't really gotten the chance to mess around with the newer versions yet, so I can't say there...  thanks for the input though, good to know :D
Logged
On the Wall is a Masterfully engraved carving of Urist McHardcastle and Goblins. Urist McHardcastle is surrounded by the Goblins. The Golbins are stamping on Urist McHardcastle. Urist McHardcaste is laughing at the Goblins. The carving related to the prolonged and bloody death of Urist McHardcastle in the Fall of 1659, the Winter of 1659, and the Spring of 1660. On the engraving is an image of Cheese.

Hummingbird

  • Bay Watcher
    • View Profile

I pasted the world history file into the World History to XML Converter, and pressed "^To XML v"—nothing happened.
Logged
But Elves aren't Vegetarians. They eat people.
So they are humanitarians.

Scarpa

  • Bay Watcher
    • View Profile

The History to XML web page is not working for me either. Same issue as Hummingbird.

I have run into two issues so far, one was a problem with a special character in a world name and the other is with malformed XML.

The first issue I have to look into more to get you more information.

The other issue is with the empty ruler lists. Specifically, if the last civilization in the world history file has an empty ruler list this is what you get in the XML output:

Code: [Select]
<rulers>
<ruler>
</rulers>

If a civilization with an empty ruler list is followed by another civilization you handle it correctly and this is produced:

Code: [Select]
<rulers>
</rulers>

I have been thinking about a Legend browser type project since I heard Toady was thinking about XML output. I want to make something completely browser driven and to start I am messing with XSL stylesheets.

Here is a stylesheet I put together this afternoon. Save the contents as history.xsl or something, and reference it from the xml file by adding the following tag:
Code: [Select]
<?xml-stylesheet type="text/xsl" href="history.xsl"?>
Then when you view the XML file in browser it will transform the data to html using the stylesheet.

Spoiler (click to show/hide)

edit: Cleaned up stylesheet so races weren't hard coded.
« Last Edit: March 06, 2010, 10:59:26 pm by Scarpa »
Logged

Sizik

  • Bay Watcher
    • View Profile

In the sites and populations converter, names with non-ASCII characters cause the <site>, <id>, <name>, <translation>, and <type> tags to not appear, just leaving a list of creatures.
Example:
Input text:
Code: [Select]
1: Gozru Ospsƒs, "The Hell of Neutralization", a cave
1 cyclops
1 cougar
6 ratmen
332 purring maggots
352 cave spiders
444 bats
2: Nanggo‰sru, "The Ashamed Crevices", a cave
5 trolls
395 bats
3: Ilusoggez, "The Everseeing Hole", a cave
1 alligator
5 giant cave swallows
251 bats
254 purring maggots
4: Omana, "Bursthole", a cave
1 alligator
1 giant mole
3 trolls
313 purring maggots
334 bats
5: „olpusedme, "The Impure Murk", a cave
1 grizzly bear
1 black bear
5 giant rats
364 bats
420 cave spiders
6: Tosnospos Nelo Omstu, "Weaknessabyss the Defects of Worrying", a cave
...
(Note: in DF these names would be Gozru Ospsâs, Nanggoësru, and Ńolpusedme)
Output XML:
Code: [Select]
<world>
<creature>
<name>cyclops</name>
<number>1</number>
</creature>
<creature>
<name>cougar</name>
<number>1</number>
</creature>
<creature>
<name>ratmen</name>
<number>6</number>
</creature>
<creature>
<name>purring maggots</name>
<number>332</number>
</creature>
<creature>
<name>cave spiders</name>
<number>352</number>
</creature>
<creature>
<name>bats</name>
<number>444</number>
</creature>
<creature>
<name>trolls</name>
<number>5</number>
</creature>
<creature>
<name>bats</name>
<number>395</number>
</creature>
<site>
<id>3</id>
<name>Ilusoggez</name>
<translation>The Everseeing Hole</translation>
<type>a cave</type>
<creature>
<name>alligator</name>
<number>1</number>
</creature>
<creature>
<name>giant cave swallows</name>
<number>5</number>
</creature>
<creature>
<name>bats</name>
<number>251</number>
</creature>
<creature>
<name>purring maggots</name>
<number>254</number>
</creature>
</site>
<site>
<id>4</id>
<name>Omana</name>
<translation>Bursthole</translation>
<type>a cave</type>
<creature>
<name>alligator</name>
<number>1</number>
</creature>
<creature>
<name>giant mole</name>
<number>1</number>
</creature>
<creature>
<name>trolls</name>
<number>3</number>
</creature>
<creature>
<name>purring maggots</name>
<number>313</number>
</creature>
<creature>
<name>bats</name>
<number>334</number>
</creature>
<creature>
<name>grizzly bear</name>
<number>1</number>
</creature>
<creature>
<name>black bear</name>
<number>1</number>
</creature>
<creature>
<name>giant rats</name>
<number>5</number>
</creature>
<creature>
<name>bats</name>
<number>364</number>
</creature>
<creature>
<name>cave spiders</name>
<number>420</number>
</creature>
</site>
<site>
<id>6</id>
<name>Tosnospos Nelo Omstu</name>
<translation>Weaknessabyss the Defects of Worrying</translation>
<type>a cave</type>
...

See how the first two sites are only a list of animals, and the creatures from the fifth site are merged into the fourth site.

Also, it doesn't include the
   Unnumbered beetles
   Unnumbered worms
   Unnumbered ants
at the end of the file.

And I can't get the history converter to work at all.
Logged
Skyscrapes, the Tower-Fortress, finally complete!
Skyscrapes 2, repelling the zombie horde!
Pages: [1] 2