Feche1320 Posted February 28, 2012 Share Posted February 28, 2012 I have this xml file: <ghost> <settings racerName="~[ERU]~Feche" startPosX="2495.7998046875" startPosY="-1675.5" startPosZ="13" startRotX="0" startRotY="0" startRotZ="81.996459960938" vehModel="522"></settings> <upd pKey="accelerate" pKeyState="true" posUpdX="2495.7998046875" posUpdY="-1675.5" posUpdZ="13" posUpdRotX="0" posUpdRotY="0" posUpdRotZ="81.996459960938" posUpdVelX="0" posUpdVelY="0" posUpdVelZ="0" vehHealth="1000"></upd> <upd pKey="vehicle_left" pKeyState="true" posUpdX="2495.7998046875" posUpdY="-1675.5" posUpdZ="13" posUpdRotX="0" posUpdRotY="0" posUpdRotZ="81.996459960938" posUpdVelX="0" posUpdVelY="0" posUpdVelZ="0" vehHealth="1000"></upd> <upd pKey="accelerate" pKeyState="continue" posUpdX="2495.2534179688" posUpdY="-1675.5454101563" posUpdZ="12.892325401306" posUpdRotX="10.0966796875" posUpdRotY="359.65002441406" posUpdRotZ="87.779418945313" posUpdVelX="-0.074961133301258" posUpdVelY="-0.01361764408648" posUpdVelZ="0.0040890411473811" vehHealth="1000"></upd> <upd pKey="vehicle_left" pKeyState="continue" posUpdX="2495.2534179688" posUpdY="-1675.5454101563" posUpdZ="12.892325401306" posUpdRotX="10.0966796875" posUpdRotY="359.65002441406" posUpdRotZ="87.779418945313" posUpdVelX="-0.074961133301258" posUpdVelY="-0.01361764408648" posUpdVelZ="0.0040890411473811" vehHealth="1000"></upd> <upd pKey="accelerate" pKeyState="continue" posUpdX="2493.69921875" posUpdY="-1676.0760498047" posUpdZ="12.882439613342" posUpdRotX="6.873291015625" posUpdRotY="0.0048828125" posUpdRotZ="108.62701416016" posUpdVelX="-0.14514435827732" posUpdVelY="-0.065354496240616" posUpdVelZ="-0.0011712360428646" vehHealth="1000"></upd> <upd pKey="vehicle_left" pKeyState="false" posUpdX="2493.69921875" posUpdY="-1676.0760498047" posUpdZ="12.882439613342" posUpdRotX="6.873291015625" posUpdRotY="0.0048828125" posUpdRotZ="108.62701416016" posUpdVelX="-0.14514435827732" posUpdVelY="-0.065354496240616" posUpdVelZ="-0.0011712360428646" vehHealth="1000"></upd> <upd pKey="accelerate" pKeyState="false" posUpdX="2491.25" posUpdY="-1676.6632080078" posUpdZ="12.906914710999" posUpdRotX="1.2957763671875" posUpdRotY="0.072265625" posUpdRotZ="98.93408203125" posUpdVelX="-0.19663426280022" posUpdVelY="-0.0084514888003469" posUpdVelZ="0.0021100479643792" vehHealth="1000"></upd> <upd pKey="vehicle_right" pKeyState="true" posUpdX="2491.25" posUpdY="-1676.6632080078" posUpdZ="12.906914710999" posUpdRotX="1.2957763671875" posUpdRotY="0.072265625" posUpdRotZ="98.93408203125" posUpdVelX="-0.19663426280022" posUpdVelY="-0.0084514888003469" posUpdVelZ="0.0021100479643792" vehHealth="1000"></upd> <upd pKey="accelerate" pKeyState="true" posUpdX="2488.7902832031" posUpdY="-1675.7800292969" posUpdZ="12.893157958984" posUpdRotX="359.48352050781" posUpdRotY="358.77807617188" posUpdRotZ="63.678771972656" posUpdVelX="-0.16058538854122" posUpdVelY="0.11217575520277" posUpdVelZ="-0.00058749318122864" vehHealth="1000"></upd> <upd pKey="vehicle_right" pKeyState="false" posUpdX="2488.7902832031" posUpdY="-1675.7800292969" posUpdZ="12.893157958984" posUpdRotX="359.48352050781" posUpdRotY="358.77807617188" posUpdRotZ="63.678771972656" posUpdVelX="-0.16058538854122" posUpdVelY="0.11217575520277" posUpdVelZ="-0.00058749318122864" vehHealth="1000"></upd> <upd pKey="accelerate" pKeyState="false" posUpdX="2486.5651855469" posUpdY="-1674.4409179688" posUpdZ="12.908591270447" posUpdRotX="358.16882324219" posUpdRotY="0.5020751953125" posUpdRotZ="59.870239257813" posUpdVelX="-0.16714724898338" posUpdVelY="0.095677964389324" posUpdVelZ="-0.00025970744900405" vehHealth="1000"></upd> <upd pKey="nothing" pKeyState="nothing" posUpdX="2484.3020019531" posUpdY="-1673.1380615234" posUpdZ="12.901062965393" posUpdRotX="357.06091308594" posUpdRotY="359.87268066406" posUpdRotZ="59.883239746094" posUpdVelX="-0.15138174593449" posUpdVelY="0.088615797460079" posUpdVelZ="-0.00025558628840372" vehHealth="1000"></upd> <end end="end"></end> </ghost> But, I have this problem local updTypes = { "upd", "vehiclechange", "nitro", "end" } while true do for i, t in pairs(updTypes) do info = xmlFindChild(ghost, t, count) if info then outputChatBox("Found " ..t.. " at index " ..count) end end count = count + 1 end Found upd at index 0 Found end at index 0 Found upd at index 1 Found upd at index 2 Found upd at index 3 Found upd at index 4 Found upd at index 5 Found upd at index 6 Found upd at index 7 Found upd at index 8 Found upd at index 9 Found upd at index 10 Found upd at index 11 Found end at index 0 --> I need it to be at index 11, becouse is at the end of the file.. how could I then? Link to comment
Paper Posted February 28, 2012 Share Posted February 28, 2012 Can you explain better your problem? Link to comment
Castillo Posted February 28, 2012 Share Posted February 28, 2012 local updTypes = { "upd", "vehiclechange", "nitro", "end" } local count = 1 for i, t in ipairs(updTypes) do local info = xmlFindChild(ghost, t, 0) while info do if info then outputChatBox("Found ".. t .." at index ".. count) end info = xmlFindChild(xmlFile, t, count) count = count + 1 end end The output: Found upd at index 1 Found upd at index 2 Found upd at index 3 Found upd at index 4 Found upd at index 5 Found upd at index 6 Found upd at index 7 Found upd at index 8 Found upd at index 9 Found upd at index 10 Found upd at index 11 Found upd at index 12 Found end at index 13 Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now