Показать сообщение отдельно
Старый 28.02.2007, 02:16   #5
moka
.
 
Регистрация: 05.08.2006
Сообщений: 10,429
Написано 3,454 полезных сообщений
(для 6,863 пользователей)
Re: База игры в XML

Нельзя искать в корневой ветви.
Сделай так:

<?xml version="1.0" ?>
<base>
<objects>
<entity type="monstr">
<class name="soldier"/>
<model file="monstr\soldier\tris.md2"/>
<skin file="monstr\soldier\skin.pcx"/>
<frame>
<attack1 firstkey="0" secondkey="11"/>
<attack2 firstkey="11" secondkey="29"/>
<attack3 firstkey="29" secondkey="38"/>
<attack4 firstkey="38" secondkey="44"/>
<pain1 firstkey="44" secondkey="49"/>
<pain2 firstkey="49" secondkey="54"/>
<pain3 firstkey="54" secondkey="61"/>
<pain4 firstkey="61" secondkey="79"/>
<pain5 firstkey="79" secondkey="96"/>
<run firstkey="99" secondkey="105"/>
<pain6 firstkey="126" secondkey="145"/>
<idle1 firstkey="146" secondkey="176"/>
<idle2 firstkey="175" secondkey="214"/>
<step firstkey="215" secondkey="223"/>
<idle3 firstkey="224" secondkey="247"/>
<die1 firstkey="271" secondkey="279"/>
<die2 firstkey="308" secondkey="342"/>
<die3 firstkey="343" secondkey="387"/>
<die4 firstkey="441" secondkey="464"/>
</frame>
<chardata life="80" speed="0.2" angspeed="0.5" arange="200" dammin="5" dammax="15" reloadtime="500" resfire="50" resbullet="70" resplasma="90" resfreez="1" ressuperg="10"/>
<dropitem count="4" item1="bullet2" chance1="10" item2="weapon2" chance2="5" item3="weapon3" chance3="2" item4="bullet3" chance4="3"/>
</entity>
<entity inv="armor">
<class name="bullet2"/>
<model file="inv\bullet2\bullet2.b3d"/>
<skin file="inv\bullet2\bullet2.jpg"/>
<sell money="5"/>
<weight weight="1"/>
</entity>
</objects>
</base>
И код:
worldnode = xmlNodeFind("base", worldnode)
objectsnode = xmlNodeFind("objects", worldnode)
;Get the handle of the world node
count = xmlNodeChildCount(objectsnode) ;Get the world node's child count
Stop
For i = 1 To count ;Loop through each child node of the world node
entitynode = xmlNodeChild(objectsnode, i) ;Get the child node
If xmlNodeNameGet(objectsnode) = "entity" Then ;Check if it's an entity
t$ = xmlNodeAttributeValueGet(entitynode, "type")
;Get the entity type
End If

If t = "monstr" Then
class = xmlnodefind("class",entitynode)
monstr.monstr = New monstr
monstr\name$ = xmlNodeAttributeValueGet(class, "name")
model = xmlnodefind("model",entitynode)
monstr\model$ = xmlNodeAttributeValueGet(model, "file")
skin = xmlnodefind("skin",entitynode)
...

dropitem = xmlnodefind("dropitem",entitynode)
count = xmlNodeAttributeValueGet(dropitem, "count")

For j=count To 1 Step -1
monstr\dropitems.dropitem = New dropitem
monstr\dropitems\name$ = xmlNodeAttributeValueGet(dropitem, "item"+Str$(j))
monstr\dropitems\chance = xmlNodeAttributeValueGet(dropitem, "chance"+Str$(j))
Next

End If

Next
Перенесли потомучто это не относится к разработке библиотек, и не к 3д графике, поэтому в 2д. Подобной тематики темы в 2д. Всё правельно. ТЕмболее вопрос не относительно функционированию библиотеки, или её багов, ну и подобного, вопрос относительно ситуации, а то что используется библиотека это второстепенно. Надеюсь администрация, поэтому перенесла.
(Offline)
 
Ответить с цитированием