Roll20 uses cookies to improve your experience on our site. Cookies enable you to enjoy certain features, social sharing functionality, and tailor message and display ads to your interests on our site and others. They also help us understand how our site is being used. By continuing to use our site, you consent to our use of cookies. Update your cookie preferences .
×
Create a free account

Creating a character sheet with macros based on XML from Wizards Adventure Tools

February 28 (11 years ago)
I don't think it would be all that difficult to write a separate program that could take the xml file and create text output that could then be copy/paste into the chat window where the API script picks it up and creates a character sheet with macros and attributes.

I would model it on the beautiful work done by others here:
https://app.roll20.net/forum/post/673780/script-cu...

The desktop app would take the xml and create output:
!monster --name|Orc Warrior --Attributes(Dexterity etc) --Powers....

This script could call upon the power card script linked to above for the creation of macros.

The end result would be as a DM in 4e you go into adventure tools, find the monster you want, export it to your desktop, run the desktop app, copy and paste text into roll20 and voila a character sheet complete with macros for all of the powers as well as attributes and stats like HP, initiative, etc. The macros for the powers output beautifully with the power card script linked above.

There would be many cases where the script wouldn't know how to handle certain powers in teh xml. The advanced version could have a UI that allows for the user to edit powers etc before producing the text output. The UI could display sections of XML it doesn't know what to do with and then as the user you could create a power manually or whatever based on the xml.

This is possible right? Am I missing anything?

I don't have a lot of time really but I might work on this. It would be pretty awesome.
February 28 (11 years ago)
Alex L.
Pro
Sheet Author
OK I will start out with some friendly advice, if you don't think something would be all that difficult but yet you (or someone else) haven't already made it and you still feel the need to post about it you are most likely wrong.

The first thing you need to understand is the XML doesn't have a set layout, it a serialization of objects, it wasnt ment for other programs to read it was ment to save and load data for their app, as such it often changes.

In the end you would end up with a very poor app or a never ending job.
February 28 (11 years ago)
The WotC DDI Builder XML files are absolute garbage. There's a reason there are so few places to upload the builder files. A friend is working on a parser and display for them... and sometimes, I think it'd be easier to just build an entirely new character builder from scratch.
February 28 (11 years ago)
If you want to cheat, this does a decent job at converting some of the basic stats from the dnd4e XML to JSON.

https://dl.dropboxusercontent.com/u/454578/dnd4eTo...


You can extend it a bit more, but if you want to get all the info you'll need to parse the XML. If you've scraped the contents of the Adventure Tools, the XML is very consistent between monsters but you can tell where things were tacked on. Monsters and PCs XML are pretty much the same, so if you manage one you can do the other as well.



March 01 (11 years ago)
Lithl
Pro
Sheet Author
API Scripter

Alex L. said:

The first thing you need to understand is the XML doesn't have a set layout, it a serialization of objects, it wasnt ment for other programs to read it was ment to save and load data for their app, as such it often changes.

XML is almost trivial to read... if someone else has written the lexer and parser for you! =)

Fortunately, most browsers have a built-in XML parser. Unfortunately, we don't have access to it in the sandbox. The smallest implementation I can find is >200K, split into over a dozen files.

March 01 (11 years ago)
Alex L.
Pro
Sheet Author

Brian said:

Alex L. said:

The first thing you need to understand is the XML doesn't have a set layout, it a serialization of objects, it wasnt ment for other programs to read it was ment to save and load data for their app, as such it often changes.

XML is almost trivial to read..


It doesn't matter if you can read XML that is just a way of storing data, the XML data stored is a direct serialization of objects from the builder., they were never ment for anyone without the propper deserializer to ever read, and it can and has changed parts of the format enouth to break serveral applications on almost a weekly basis, not to mention the huge diversity of skills and possible layouts.


March 01 (11 years ago)
When I first posted I hadn't looked at the xml in detail. The xml generated by the character builder specifically looks very messy.

Alex do you know for sure that the xml produced changes on a weekly basis? Is it still changing now that they aren't producing content for 4e anymore?

I have a lot of experience with xml. The whole premise of xml is to have data be readable and useable. With the help of a UI it might be possible to create a program that would significantly speed up character and macro creation for players and monster creation for DM's.

If I get some spare time I'll work on it.
March 01 (11 years ago)

HoneyBadger said:

The WotC DDI Builder XML files are absolute garbage. There's a reason there are so few places to upload the builder files. A friend is working on a parser and display for them... and sometimes, I think it'd be easier to just build an entirely new character builder from scratch.

Would your friend share the code hes got so far? What language?

March 01 (11 years ago)
Alex L.
Pro
Sheet Author

Pugzebub said:

When I first posted I hadn't looked at the xml in detail. The xml generated by the character builder specifically looks very messy.

Alex do you know for sure that the xml produced changes on a weekly basis? Is it still changing now that they aren't producing content for 4e anymore?

I have a lot of experience with xml. The whole premise of xml is to have data be readable and useable. With the help of a UI it might be possible to create a program that would significantly speed up character and macro creation for players and monster creation for DM's.

If I get some spare time I'll work on it.


It has changed on a weekly basis, and it will tend to change when ever someone decides to change the back-end object or any number of things, also to my knowledge dragon magazine still deals with 4e for the time being.
March 07 (11 years ago)
The XML is really not that hard to work with. Here are 20 lines of Ruby that convert basic attacks to HoneyBadger's custom power cards format. Totally incomplete but should give an idea of how easy it would be to convert in bulk.

require 'nokogiri'

monster = Nokogiri::XML.parse(File.read(ARGV[0]))

powers = monster.xpath('//Powers/MonsterPower').map do |power|
  {
    name: power.xpath('./Name').text,
    defense: power.xpath('.//Defense/id').text,
    damage: power.xpath('.//Hit/Damage/Expression').text,
    type: power.xpath('.//Hit/Damage/AverageDamage/Type').text,
    leftsub: power.xpath('./Usage').text,
    rightsub: power.xpath('./Action').text
  }
end

powers.each do |power|
  options = power.each.map{|opt,val| "--#{opt}|#{val}"}
  command = ["!power", options].join(' ')
  puts command
end
March 07 (11 years ago)

Edited March 07 (11 years ago)
Whoa cool. I wish the monster entries from DDI were that easy to work with. >_<

-edit- Doh... I just re-read the initial post and realized you can export monsters into XML. That is soooo going to make my life easier with my monster importer.
March 07 (11 years ago)
Nice work Honey.

Thanks for the code John.

I still think what would be best is some kind of desktop or web application that allows you to modify everything after the XML has been imported. This way if there is some weird power that wasn't handled properly by the import you can still edit things manually trhough the application and then export the script over to roll20.

I'm so busy right now with work but I have the beginnings of something in the works atm.

I have never used ruby/rails but I imagine it could be setup as a web application. It wouldn't be hard. Just a bunch of text boxes and a list for powers.

David

March 07 (11 years ago)
If you want to go the Ruby way, it could be a super light app using Sinatra and run on Heroku for free...
March 07 (11 years ago)
I no longer work as a programmer (I have a comp sci degree and worked for 3 years predominantly with c# and java) and I'm not familiar with ruby/sinatra/heroku. I've heard of Ruby but thats about it.

Can you send a few links my way to help get me started? I wrote a bit of code to parse the xml in c# and it all started coming back to me pretty quick. I'd like to play around with Ruby and see if I can figure something out.

March 07 (11 years ago)
Whoa cool. Javascript has an xpath option too.
March 08 (11 years ago)
And I cannot get xpath in javascript to work... anyone know a really good, simple tutorial site for using xpath stuff in javascript?
March 08 (11 years ago)
Pugzebub:
http://rubykoans.com/
http://www.sinatrarb.com/
http://nokogiri.org/
https://www.heroku.com/

HoneyBager - I don't believe Node.js has built-in XML parsing. Browsers support it for working with the DOM, but that doesn't apply in our case.
March 08 (11 years ago)
Well that bites. Ah well... parsing the xml file will be much easier than parsing plain text from the compendium.
This post will have absolutely no constructive assistance to everything going on.. however it will be full of support and express how excited I am for this script and another great HBScript!

*woo*
March 08 (11 years ago)
I love the rubykoans. I teach meditation as part of my job now so it is a nice fit for me.

Although I may never finish I am going to explore ruby and see if I can get something setup.

In the meantime I hope HoneyB gets something working soon :)

Thanks
March 08 (11 years ago)
I got started on re-writing my D&D 4e monster importer last night. Most of my time was spent learning how to use xpath in javascript, only to learn that it doesn't work.... so I went through the XML file to learn where all the information is kept and how to best extract it. I've already got the Monster Name, Ability Scores, and Defenses importing into Roll20. Going to tackle skills and the rest of the base numbers next before diving into powers.
March 08 (11 years ago)
That's amazing. I'm excited.

pugz
March 08 (11 years ago)
Keep it in check... lol. I have a game I'm playing right now and will only get a couple hours after to work on it.
March 10 (11 years ago)

John M. said:

If you want to cheat, this does a decent job at converting some of the basic stats from the dnd4e XML to JSON.

https://dl.dropboxusercontent.com/u/454578/dnd4eTo...


You can extend it a bit more, but if you want to get all the info you'll need to parse the XML. If you've scraped the contents of the Adventure Tools, the XML is very consistent between monsters but you can tell where things were tacked on. Monsters and PCs XML are pretty much the same, so if you manage one you can do the other as well.

How would I use this inside Roll20 though?
March 10 (11 years ago)
Alex L.
Pro
Sheet Author

HoneyBadger said:

John M. said:

If you want to cheat, this does a decent job at converting some of the basic stats from the dnd4e XML to JSON.

https://dl.dropboxusercontent.com/u/454578/dnd4eTo...


You can extend it a bit more, but if you want to get all the info you'll need to parse the XML. If you've scraped the contents of the Adventure Tools, the XML is very consistent between monsters but you can tell where things were tacked on. Monsters and PCs XML are pretty much the same, so if you manage one you can do the other as well.

How would I use this inside Roll20 though?

You wouldn't, in the API all you do is convert XML to JSON then you are done (using some regex), no need for anything more than that.