Looks pretty good, but I think we should keep values as attributes and only use elements/nodes to give structure to the file, here is you filed corrected according to this:
- {l Code}: {l Select All Code}
<?xml version="1.0" encoding="UTF-8" ?>
<creaturetype name="foobar" meshname="foobar.mesh" class="BasicWorker"
bedname="foobarbed">
<!-- etc -->
<materials>
<!-- For most creatures/objects we just want a normal mapped or per pixel lighting material, and specify textures, and optionally lighting parameters -->
<generated name="foobarmaterial" type="normalmap_multipass" space="tangent">
<texture type="diffuse"/ filename="foobar.png"> <!-- There can be multiple of these -->
<texture type="normalmap" filename="foobar_nm.png"/>
<specular value1="0.5" value2="0.5" value3="0.5" value4="1" value5="20"/> <!-- I did not know what to call these attributes -->
<diffuse value1="1.0" value2="0.5" value3="0.5" value4="1"/> <!-- Again I do not know what they should be called -->
<!-- etc -->
</generated>
<custom name="foobarmaterial" filename="foobar.material />
</materials>
<sounds>
<sound filename="foobar.ogg" animation="dig" volume="0.8" frame="23"/>
</sounds>
<ai filename="foobarai.as"/>
</creaturetype>
StefanP.MUC {l Wrote}:Attributes are good
Agreed
StefanP.MUC {l Wrote}:In the end we should also provide a graphical editor for the creatures (maybe directly from the game), then the user won't have to care about the internals anyways.
Yep that would be very useful when syncing the sounds to the animations. Also I added the volume for each sound file above and changed the delay to a frame attribute that refers to the mesh animation frame where the sound should be played.
Knitter {l Wrote}:You can use attributes for whatever you want but they were created for one single purpose: meta-data.
Attributes are meant to give information about the data stored not to store data themselves, everything that is relevant should be an element. Still, nothing prevents you from putting data in attributes instead of elements.
Personally I feel that using attributes for data is wrong, but may be due to having worked with XML for quite some time and used some libraries that didn't support attributes.
In my opinion attributes can store both data and metadata, but elements should not store data them-self i.e. in the element, unless they store text or blobs of binary data, elements should only define structure the xml files.