Arsilex Posted January 16, 2015 Posted January 16, 2015 Hello guys i have this code: local metaXML = xmlLoadFile(":"..path.."/meta.xml") if metaXML then for i, m in ipairs(xmlNodeGetChildren(metaXML)) do local metaXMLName = xmlNodeGetName(m) but i have this error: i'm sure that the "m" argument is a node-xml element.
ViRuZGamiing Posted January 16, 2015 Posted January 16, 2015 Try using debugOutputString on metaXML and make, xmlNodeGetChildren(metaXML) a seperate variable. local metaXML = xmlLoadFile(":"..path.."/meta.xml") outputDebugString(tostring(metaXML)) if (metaXML) then local metaChildern = xmlNodeGetChildren(metaXML) outputDebugString(tostring(metaChildern)) for i, m in ipairs(metaChildern) do local metaXMLName = xmlNodeGetName(m) Then tell me what's in your /debugscript 3 regards viruz "If debugging is the process of removing software bugs, then programming must be the process of putting them in."
Arsilex Posted January 16, 2015 Author Posted January 16, 2015 There is the return of the outputDebugString: meta: userdata: 0x100ff18 xmlNodeGetChildren: table: 0x1641870
Dealman Posted January 17, 2015 Posted January 17, 2015 It returns a table of children, make a new for loop to loop through them. A table is not an XML Node. local metaXML = xmlLoadFile(":"..path.."/meta.xml") if (metaXML) then local metaChildern = xmlNodeGetChildren(metaXML) for i, m in ipairs(metaChildern) do for k, v in ipairs(m) do outputDebugString(tostring(xmlNodeGetName(v))) end end end If I help you in a thread and you need further assistance, please don't PM me - use the thread you created instead. This way everyone on the forum can take advantage of it.
ViRuZGamiing Posted January 17, 2015 Posted January 17, 2015 Yeah my bad, dealman "If debugging is the process of removing software bugs, then programming must be the process of putting them in."
Arsilex Posted January 17, 2015 Author Posted January 17, 2015 for i, m in ipairs(metaChildern) do m return a node. if you dont see the outputDebugString is under local metaChildern = xmlNodeGetChildren(metaXML) so this need to return table if i will put the outputDebugString into a loop i will get a node and i get it but the script make a error.
Arsilex Posted January 17, 2015 Author Posted January 17, 2015 i try to do this: for i, m in ipairs(metaChildern) do outputChatBox(tostring(xmlNodeGetName(m))) and i have this: info false false false false false
ViRuZGamiing Posted January 17, 2015 Posted January 17, 2015 so your childern from metaChildern return false, Show your XML. "If debugging is the process of removing software bugs, then programming must be the process of putting them in."
Arsilex Posted January 17, 2015 Author Posted January 17, 2015 <?xml version="1.0"?> type="script" version="1.0.0" author="AsuS" name="Test"/>
ViRuZGamiing Posted January 17, 2015 Posted January 17, 2015 BTW, If the file is in the current resource, only the file path is necessary, e.g. xmlLoadFile("settings.xml") "If debugging is the process of removing software bugs, then programming must be the process of putting them in."
Arsilex Posted January 17, 2015 Author Posted January 17, 2015 yes that works if the is the same script but i used this line to read the meta.xml from another resource.
Et-win Posted January 17, 2015 Posted January 17, 2015 What do you want to do with the script? ~Scripts~ Clan War System V1.2.0 ~Maps~ [DM]Et-win - The Run [FUN]Et-win - Drift Rocket [FUN]Et-win - Drift Rocket // [DD]Et-win - Cross 3xC
Arsilex Posted January 17, 2015 Author Posted January 17, 2015 This script need to get the information from the meta.xml like script linked to they and download all that after whit loader load the code from .lua
novo Posted January 17, 2015 Posted January 17, 2015 Well, I suppose you've changed the meta.xml file you're trying to read since the first post - so I'll rather give you a working example based on a sample meta file. <meta> <file src="song.mp3" /> <script src="client.lua" type="client" /> <info gamemodes="race" type="map" name="Example" /> <map src="example.map" dimension="0" /> <settings> <setting name="#respawn" value='[ "none" ]' /> </settings> </meta> local meta = xmlLoadFile(":"..resource.."/meta.xml") local nodes = xmlNodeGetChildren(meta) local files = {} local _settings = {} for i,v in ipairs(nodes) do local attributes = xmlNodeGetAttributes(v) local type = xmlNodeGetName(v) if type == "file" then table.insert(files, attributes.src) -- song.mp3 / any file elseif type == "settings" then local settings = xmlNodeGetChildren(v) -- As settings in this case contains sub-nodes, we retrieve and loop over them for i,v in ipairs(settings) do local attributes = xmlNodeGetAttributes(v) if attributes.name == "#respawn" then table.insert(_settings, {attributes.name, attributes.value}) -- #respawn, [ "none" ] / any node's attributes inside "settings" end end end end
Et-win Posted January 18, 2015 Posted January 18, 2015 Well, you can just use the example on the wiki (xmlNodeGetChildren) and change 'xmlNodeGetValue' to 'xmlNodeGetName'. ~Scripts~ Clan War System V1.2.0 ~Maps~ [DM]Et-win - The Run [FUN]Et-win - Drift Rocket [FUN]Et-win - Drift Rocket // [DD]Et-win - Cross 3xC
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