Page 1 of 1

Resources are now json formatted

Posted: Sat Feb 09, 2013 6:32 pm
by oskarwiksten
Hi,

I just committed a major change to the master branch of our git repository, which affects the development aspect of Andor's Trail profoundly.

You know that old resource format we used to use - with the excessive use of | signs everywhere, and the funky use of "{}" and "[]" everywhere. It's gone.
We now encode all our resources as json objects. I rewrote the parsers for the resourceloaders to parse json objects instead, and also updated the editor to import/export as json. (The editor can still import stuff from the old resource format though).

The reasoning behind this change is twofold:
  1. We can now use standardized tools to read and manipulate the resource files. Json is a versatile format, which most languages have native support for.
  2. By keeping the field names close to each object definition, we won't have to change all of the existing objects when introducing new fields.
I'm so satisfied with this change, I'm almost jumping with joy. We seem to have discussed introducing new properties on items and monsters for as long as this project has been around, and now another hurdle on the way of making flexible resources has been overcome. For example, if we want to introduce "items that give actor condition resistances", it would be a minor change to only add such a property to the new items that would have that property, instead of updating all of the existing items (including all translations). Other properties on monsters, items, actor conditions, conversations, or quests would be equally easy to implement now.

So, what are your thoughts? What other clever things can we do, now that the resources can be loaded as json objects?
As a nudge to all developers, imagine what you could do by loading an url like this with jquery on a webpage:
http://andors-trail.googlecode.com/git/ ... _v068.json
(all game resources are available in similar files)

Oh, another thing. While updating the editor to support the new json format, the code was refactored it to use angular.js insted of jqueryui. Additionally, the content editor now has a lot of new nifty features:
  • Editor can now import content from the git repository (available from the top right "import" button)
  • Table-based editors for items and monsters (for power-users)
  • Mouseover-hints for most labels in the editor.
  • Exp calculation for monsters now take conditions into effect (thanks to Ian for reporting it!)
As before, the editor can be found at:
http://andors-trail.googlecode.com/git/ ... ditor.html

RIP home-grown resource format. Long live the json resource format!

Would love to hear the input from other developers!

Re: Resources are now json formatted

Posted: Sat Feb 09, 2013 6:39 pm
by oskarwiksten
Also, please let us know if the updated content editor doesn't work on your browser!

Re: Resources are now json formatted

Posted: Sat Feb 09, 2013 6:56 pm
by Tomcat
I have a quick question ...

I see people often posting new proposed quests, mobs, etc. directly in the old resource format. Is the new one also a text format, or does it need to be exported in order to post it?

Re: Resources are now json formatted

Posted: Sat Feb 09, 2013 7:00 pm
by oskarwiksten
Tomcat wrote:Is the new one also a text format, or does it need to be exported in order to post it?
Relevant question, Tomcat! Json is also text, so it should be similar. In fact, json is even more readable than the old format.
The content editor can even import the old format, so older posts that use the old format can still be used.

Re: Resources are now json formatted

Posted: Sun Feb 10, 2013 3:48 am
by sdevaney
oskarwiksten wrote:
Tomcat wrote:Is the new one also a text format, or does it need to be exported in order to post it?
Relevant question, Tomcat! Json is also text, so it should be similar. In fact, json is even more readable than the old format.
The content editor can even import the old format, so older posts that use the old format can still be used.
This x1000. As an example of how much easier this way is to read and understand....Same item different format.

Old format:
{shield6|items_armours:3|Wooden tower shield|shld_twr|||952|1|||||-6|||||12||||||||||||||||||||||};
New format:
{
"id": "shield6",
"iconID": "items_armours:3",
"name": "Wooden tower shield",
"category": "shld_twr",
"baseMarketCost": 952,
"equipEffect": {
"increaseAttackChance": -6,
"increaseBlockChance": 12
}
},
Excellent work as always!

Re: Resources are now json formatted

Posted: Sun Feb 10, 2013 3:54 am
by Tomcat
sdevaney wrote:
oskarwiksten wrote:
Tomcat wrote:Is the new one also a text format, or does it need to be exported in order to post it?
Relevant question, Tomcat! Json is also text, so it should be similar. In fact, json is even more readable than the old format.
The content editor can even import the old format, so older posts that use the old format can still be used.
This x1000. As an example of how much easier this way is to read and understand....Same item different format.

Old format:
{shield6|items_armours:3|Wooden tower shield|shld_twr|||952|1|||||-6|||||12||||||||||||||||||||||};
New format:
{
"id": "shield6",
"iconID": "items_armours:3",
"name": "Wooden tower shield",
"category": "shld_twr",
"baseMarketCost": 952,
"equipEffect": {
"increaseAttackChance": -6,
"increaseBlockChance": 12
}
},
Excellent work as always!
Yes that looks much easier! Simple pairs of attribute name and attribute value. No counting empty fields for attributes that the object doesn't use. Nice.

Re: Resources are now json formatted

Posted: Sun Feb 10, 2013 6:03 am
by Pyrizzle
Waaaaaaaay easier to understand now. I am glad we have switched!