Advertisement
Guest User

[Tfm] Crazymaps

a guest
Oct 22nd, 2014
999
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.35 KB | None | 0 0
  1.  
  2. xmlTable = {grounds = {}, xmlStart = '', xmlEnd = ''}
  3.  
  4. function parseXml()
  5. editedXml = ''
  6. editedDecorations = ''
  7. xmlTable.grounds = {}
  8. c = 0xE6FAFF
  9. id = 1
  10. color = {0xC80046,0xC80031,0xC8001B,0xC70004,0xC81300,0xC72800,0xC83B00,0xC84D00,0xC85F00,0xC77000,0xC88200,0xC89500,0xC8A900,0xC8BF00,0xB8C800,0xA1C700,0x8CC800,0x77C800,0x63C800,0x4EC800,0x38C800,0x20C800,0x06C800,0x00C815,0x00C82D,0x00C844,0x00C859,0x00C86E,0x00C783,0x00C897,0x00C7AD,0x00C8C5,0x00B3C7,0x009EC8,0x008BC8,0x0079C8,0x0067C8,0x0055C8,0x0043C8,0x0031C8,0x001CC8,0x0006C8,0x1100C8,0x2700C8,0x3C00C7,0x5100C8,0x6500C8,0x7A00C8,0x9100C8,0xA800C8}
  11.  
  12.     if tfm.get.room.xmlMapInfo.xml then
  13.         xml = tfm.get.room.xmlMapInfo.xml
  14.         grounds = xml:match('<S>[^´]+/>'):gsub("<S>","")
  15.         for id in grounds:gmatch('<S[^/]+/>') do
  16.             table.insert(xmlTable.grounds,id)
  17.         end
  18.         xmlTable.xmlStart = xml:match('<C>[^´]+<S>')
  19.         xmlTable.xmlEnd = xml:match('</S>[^´]+</C>')
  20.        
  21.         for k,v in pairs(xmlTable.grounds) do
  22.             if id < #color then
  23.                 id = id+1
  24.             else
  25.                 id = 1
  26.             end
  27.             c = color[id]
  28.             if not v:match('T="9"') then
  29.                 if not v:match('T="13"') then
  30.                     if not v:match('m=""') then
  31.                         if not v:match('o="[A-Z0-9a-z]+"') then
  32.                             v = v:gsub('T="[0-9]+"',string.format('T="12" o="%s"',string.format("%X", c)))
  33.                         else
  34.                             o = string.format('o="%s"',string.format("%X", c))
  35.                             v = v:gsub('o="[A-Z0-9a-z]+"',o)
  36.                         end
  37.                     end
  38.                 else
  39.                     if not v:match('m=""') then
  40.                         if not v:match('o="[A-Z0-9a-z]+"') then
  41.                             v = v:gsub('T="[0-9]+"',string.format('T="12" o="%s"',string.format("%X", c)))
  42.                         else
  43.                             o = string.format('o="%s"',string.format("%X", c))
  44.                             v = v:gsub('o="[A-Z0-9a-z]+"',o)
  45.                         end
  46.                     end
  47.                 end
  48.             end
  49.             editedXml = editedXml..v
  50.         end
  51.     xml = string.format("%s%s%s",xmlTable.xmlStart,editedXml,xmlTable.xmlEnd)  
  52.    
  53.     tfm.exec.newGame(xml)
  54.     cheese = {t='',x='',y=''}
  55.         if xml:match('<F[^/]+/>') then
  56.             cheese.t = xml:match('<F[^/]+/>'):gsub("<F",""):gsub("/>","")
  57.             tfm.exec.addImage('dRKmgdP.png',"!2",cheese.t:match('X="[0-9]+"'):gsub("X=",""):gsub('"',""),cheese.t:match('Y="[0-9]+"'):gsub("Y=",""):gsub('"',""))
  58.         end
  59.     end
  60. end
  61.  
  62. function eventNewGame()
  63.     if tfm.get.room.xmlMapInfo then
  64.         mapAuthor = tfm.get.room.xmlMapInfo.author
  65.         if mapAuthor ~= '#Module' then
  66.             parseXml()
  67.         end
  68.     end
  69. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement