PoliceSA Posted July 2, 2014 Share Posted July 2, 2014 (edited) function SetTime() local mapMeta = xmlLoadFile("meta.xml") local value = xmlNodeGetAttribute(mapMeta, "value") local dotPos = string.find(value,":")-- The Problem local hours = string.sub(value,1,dotPos-1) local minutes = string.sub(value,dotPos+1,string.len(value)) setTime(tonumber(hours),tonumber(minutes)) setMinuteDuration(1000000000) outputChatBox("Time Setted") end Error : bad argument #1 to 'find' string expected got boolean Edited July 2, 2014 by Guest Link to comment
PoliceSA Posted July 2, 2014 Author Share Posted July 2, 2014 Typos line 3 "valuer" no, i failed when i wrote that.. (look edit) Link to comment
myonlake Posted July 2, 2014 Share Posted July 2, 2014 Because it makes no sense. A XML handle cannot have an XML attribute, you must first find a child and then get its attribute. Link to comment
PoliceSA Posted July 2, 2014 Author Share Posted July 2, 2014 I tried with this script too : local file = xmlLoadFile("meta.xml") for i, v in ipairs(xmlNodeGetChildren(file)) do local name = xmlNodeGetName(v) if name == "settings" then local sname = xmlNodeGetAttribute(v,"name") if sname == "#time" then local value = xmlNodeGetAttribute(v, "value") if value then value = string.gsub(value, "%s+", "") value = string.gsub(value, "[%[%]]", "") setTime(value:match('(%d+)%d+)')) realtime = value else setTime(12,0) end end end end but still doesn't set the correct time Link to comment
Et-win Posted July 4, 2014 Share Posted July 4, 2014 You first have to do xmlFindChild for settings. Then do xmlNodeGetChildren. Link to comment
PoliceSA Posted July 6, 2014 Author Share Posted July 6, 2014 Can you explain better how i can do that? Link to comment
Et-win Posted July 7, 2014 Share Posted July 7, 2014 local fChild_Settings = xmlFindChild(mapMeta, "settings", 0) I bet you know the next code. 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