KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I'm dealing with game dialogue files (conversation between player and non-playable-characters) where dialogue choices and their outcome depend on certain conditions and result in certain actions. Now, I could write a simple parser to handle some sort of language for specifying the pre and post-conditions, but a friend of mine suggested using XML. Conditions could be stored as attributes of a dialogue element and choices and actions are inner elements. I'd then use an eval function to parse these conditions and statements (I'm using Ruby to make this game). To make such an approach simpler, I could then write a simple GUI to manipulate these files without worrying about ugly XML. But it strikes me as an odd choice to handle logic in XML files. My understanding is that XML files are for the storage and exchange of data, and I always read rants about how people overuse XML for all sorts of things it wasn't designed for. My friends responds by noting how XML IS used for everything, including XHTML and this bullet description language (which also illustrates some logic). To be honest, using XML would simplify a lot of things for me. Writing a parser can be painful and time consuming, and my requirements are generally simple. But is it really okay or would I regret such a choice later? For people interested in details, here's what a basic dialogue exchange might look like in an XML file: <dialogue id="101" condition="!npc.carsFixed"> <message>Man, fix my car!</message> <choices> <choice condition="hero.carFixingSkill > 5" priority="7" id="Sure!"> <command>hero.carFixingSkills += 1</command> <command>npc.carFixed = true</command> <command>hero.playSmokeAnimation()</command> <command>nextDialogue = 104</command> </choice>
Tags (comma-separated)
Save Edits
Cancel