12p Posted October 21, 2011 Share Posted October 21, 2011 (edited) Gonna update and fix my 3D Texts resource. I'm fixing the code for loading texts from XML files of a resource that is started. The trouble is "Bad argument @ xmlNodeGetChildren ( in this case, at position 5 ) function loadText ( resource ) if not resource and source then resource = source elseif not resource and not source then return end if not fileExists ( ":" .. getResourceName ( resource ) .."/texts.xml" ) then return end local node = xmlLoadFile ( ":" .. getResourceName ( resource ) .."/texts.xml" ) for i, t in ipairs ( xmlNodeGetChildren ( node ) ) do --Down this part is done, no need to show it because it has no trouble end addEventHandler ( "onResourceStart", getRootElement ( ), loadText ) The XML file I'm loading is this (it's called "texts.xml"): <texts> <text posX="4000" posY="-2729.75" posZ="6" text="Sección 1 por Benxamix2" red="64", green="128" blue="0" alpha="255" scale="2" font="bankgothic" /> </texts> What's wrong? Edited October 22, 2011 by Guest Link to comment
arezu Posted October 22, 2011 Share Posted October 22, 2011 use debugs like this to see whats wrong: function loadText ( resource ) if not resource and source then resource = source elseif not resource and not source then return end if not fileExists ( ":" .. getResourceName ( resource ) .."/texts.xml" ) then return end local node = xmlLoadFile ( ":" .. getResourceName ( resource ) .."/texts.xml" ) if(node == false)then outputChatBox("error loading file") end for i, t in ipairs ( xmlNodeGetChildren ( node ) ) do --This part is done, no need to show it because it has no trouble end addEventHandler ( "onResourceStart", getRootElement ( ), loadText ) Link to comment
12p Posted October 22, 2011 Author Share Posted October 22, 2011 Dude, don't you think that fileExists already does that? Link to comment
12p Posted October 22, 2011 Author Share Posted October 22, 2011 So... What's wrong? Nobody can tell? Link to comment
Castillo Posted October 22, 2011 Share Posted October 22, 2011 Is the resource where you call that script from in the acl? and has access to this function: ModifyOtherObjects? Because, I've loaded a texts.xml in a resource and works perfectly. Link to comment
12p Posted October 22, 2011 Author Share Posted October 22, 2011 In acl.xml I always use at Admin: <object name="resource.*" /> That's obviously not the problem. Link to comment
Castillo Posted October 22, 2011 Share Posted October 22, 2011 Is texts.xml in the meta.xml? I don't get why should work here and not for you. Link to comment
12p Posted October 22, 2011 Author Share Posted October 22, 2011 No. But actually I added it to the meta.xml before and the resource was unable to be started when it was server-side O_o, so I had to take it off. Yes in both sides, client and server. Doesn't do anything. Link to comment
Castillo Posted October 22, 2011 Share Posted October 22, 2011 This is how I got it working: Resource: 1 with the script to load the files. Resource: 2 with texts.xml file. It works with no problems. Link to comment
12p Posted October 22, 2011 Author Share Posted October 22, 2011 Okay. I got the same thing as yours and does not work. Hurray! I will try to use another resource with only texts.xml and meta.xml to see if that works. EDIT. I don't know how the hell I did it, but is fixed. Thank you anyway, dude. 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