Advertisement
Guest User

Untitled

a guest
Jan 18th, 2020
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.74 KB | None | 0 0
  1. local function initializeApplication()
  2.   local path = system.pathForFile("res/init/navigation_map.xml")
  3.  
  4.   if path then
  5.     local appMap = parseXml("res/init/navigation_map.xml")
  6.     local contents = appMap.children[1].children
  7.    
  8.     local subTrees = {}
  9.     local entry
  10.    
  11.     local function levelParser(level)
  12.       if level and level ~= {} then
  13.         local tbl = {}
  14.        
  15.         for i = 1, #level do
  16.           local str = level[i].attrs.name
  17.           local name
  18.          
  19.           if not tostring(str):find("@") then
  20.             name = "src." .. tostring(str)
  21.           else
  22.             if tostring(str)== "@exit" then
  23.               name = "exit"
  24.             elseif tostring(str):find("@url") then
  25.               name = "url here lol"
  26.             elseif tostring(str):match("@%w") then
  27.               val = tostring(str):gsub("@", "")
  28.               level[i].children = subTrees[val]
  29.               name = subTrees[val].name
  30.             end
  31.           end
  32.          
  33.           tbl[i] = {}
  34.           tbl[i][level[i].tag] = {
  35.             name = name,
  36.             levelParser(level[i].children)
  37.           }
  38.         end
  39.        
  40.         return tbl
  41.       end
  42.     end
  43.    
  44.     for i = 1, #contents do
  45.       if contents[i].tag == "define" then
  46.         subTrees[contents[i].attrs.shortName] = {
  47.           name = contents[i].attrs.name,
  48.           children = contents[i].children
  49.         }
  50.       elseif contents[i].tag == "entry" then
  51.         local name = "src." .. tostring(contents[i].attrs.name)
  52.        
  53.         entry = {
  54.           name = name,
  55.           children = contents[i].children
  56.         }
  57.       end
  58.     end
  59.    
  60.     if entry then
  61.       APPLICATION_MAP = levelParser(entry.children)
  62.     end
  63.   end
  64. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement