acp___(PL) Posted May 30, 2010 Share Posted May 30, 2010 The script that has to read the content meta.xml maps, it is run by meta.xml some (not all) maps. It is meta.xml of map: <?xml version="1.0" encoding="utf-16"?> <meta> <include resource="2paq_laptimer" /> (...) <settings> (...) <setting name="#laps" value="[14]" /> </settings> </meta> script I run something I need to read I tried this script, but I have error: ERROR: ...source-cache/unzipped/2paq_laptimer/lapcounter_s.lua:6: attempt to call global 'getRunningGamemodeMap' (a nil value) local g_rot = getRootElement() local g_ResRoot = getResourceRootElement(getThisResource()) local numberOfAllLaps = -1 function readNumberOfLapsFromMeta() local meta = xmlLoadFile(':' ..getResourceName( getRunningGamemodeMap() ) .. '/' .. 'meta.xml') if not meta then outputDebugString('Error while loading meta.xml - lap counter: no meta.xml', 2) return false end local settingsNode = xmlFindChild(meta, 'settings', 0) if not settingsNode then outputDebugString('Error while loading meta.xml - lap counter: no <settings>', 2) return false end local i_xmlSetting = 0 xml_setting = xmlFindChild(settingsNode, 'setting', i_xmlSetting) while xml_setting do if xmlNodeGetAttributes(xml_setting) then local attrs = xmlNodeGetAttributes(xml_setting) if attrs.name == laps then numberOfAllLaps = attrs.value readNumberOfLaps() break end end i_xmlSetting = i_xmlSetting + 1 end end Link to comment
Dark Dragon Posted May 30, 2010 Share Posted May 30, 2010 there is no such function, it's an exported function from the resource mapmanager. use call to use exported functions Link to comment
acp___(PL) Posted May 30, 2010 Author Share Posted May 30, 2010 local meta = xmlLoadFile(':' ..getResourceName( exports.mapmanager:getRunningGamemodeMap() ) .. '/' .. 'meta.xml') ERROR: xmlLoadFile failed; ModifyOtherObjects in ACL denied resource 2paq_laptimer to access race-australiangp I hope that when added 2paq_laptimer to the ACL will work Link to comment
acp___(PL) Posted May 30, 2010 Author Share Posted May 30, 2010 The first part work: INFO: Loading meta.xml - lap counter: race-wurstsaustraliangp function readNumberOfLapsFromMeta() local meta = xmlLoadFile(':' ..getResourceName( exports.mapmanager:getRunningGamemodeMap() ) .. '/' .. 'meta.xml') outputDebugString('Loading meta.xml - lap counter: '..getResourceName( exports.mapmanager:getRunningGamemodeMap() ), 3) if not meta then outputDebugString('Error while loading meta.xml - lap counter: no meta.xml', 2) return false end local settingsNode = xmlFindChild(meta, 'settings', 0) if not settingsNode then outputDebugString('Error while loading meta.xml - lap counter: no <settings>', 2) return false end ERROR: ERROR: Infinite/too long execution (2paq_laptimer) local i_xmlSetting = 0 xml_setting = xmlFindChild(settingsNode, 'setting', i_xmlSetting) while xml_setting do if xmlNodeGetAttributes(xml_setting) then local attrs = xmlNodeGetAttributes(xml_setting) if attrs.name == laps then numberOfAllLaps = attrs.value readNumberOfLaps() break end end i_xmlSetting = i_xmlSetting + 1 end end what do I wrong? Edit: xml_setting = xmlFindChild(settingsNode, 'setting', i_xmlSetting) while xml_setting do if xmlNodeGetAttributes(xml_setting) then local attrs = xmlNodeGetAttributes(xml_setting) if attrs.name == "laps" then numberOfAllLaps = attrs.value readNumberOfLaps() break end end i_xmlSetting = i_xmlSetting + 1 xml_setting = xmlFindChild(settingsNode, 'setting', i_xmlSetting) end Link to comment
eAi Posted May 30, 2010 Share Posted May 30, 2010 You're not meant to read the settings data directly, as this can be overridden by admins. Link to comment
Dark Dragon Posted May 30, 2010 Share Posted May 30, 2010 I think what you want to do can be done a lot easier local numberOfAllLaps = get(getResourceName(call(getResourceFromName("mapmanager"),"getRunningGamemodeMap"))..".laps") Link to comment
acp___(PL) Posted May 31, 2010 Author Share Posted May 31, 2010 works! very thanks for your help! I hope that the subject is clear and will also help another person 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