Rawoas13

Untitled

Apr 2nd, 2020
357
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.01 KB | None | 0 0
  1. --Creator: Bolodefchoco
  2. --Made in: 17/07/2015
  3. --Last update: 20/10/2019
  4. --[[ Notes:
  5.     Does:
  6.         Captura o XML de um mapa (Exceto vanillas)
  7.     Keys:
  8.         P --> Recarrega o mapa atual.
  9.         Espaço --> Captura o XML e imprime-o em #lua
  10. ]]--
  11.  
  12. do
  13.     local _, err = pcall(nil)
  14.     local roomOwner = string.match(err, "(.-)%.")
  15.  
  16.     system.bindKeyboard(roomOwner, 32, true)
  17.     system.bindKeyboard(roomOwner, 80, true)
  18. end
  19.  
  20. tfm.exec.newGame("#1")
  21.  
  22. eventKeyboard = function(_, key)
  23.     if key == 80 then -- P, loads the same map
  24.         tfm.exec.newGame(tfm.get.room.currentMap)
  25.     else -- Space, print XML
  26.         local xml = tfm.get.room.xmlMapInfo
  27.         if xml then
  28.             xml = xml.xml
  29.  
  30.             -- Minify
  31.             xml = string.gsub(xml, ",0,", ",,")
  32.             xml = string.gsub(xml, "([^%.%d])0+", "%1")
  33.             xml = string.gsub(xml, "(%D)0(%.)", "%1%2")
  34.    
  35.             -- Fix
  36.             xml = string.gsub(xml, "<", "&lt;")
  37.  
  38.             -- Display
  39.             print("<R>" .. tfm.get.room.currentMap .. "'s XML:")
  40.             for s = 1, #xml, 4500 do
  41.                 print(string.sub(xml, s, s + 4499))
  42.             end
  43.         end
  44.     end
  45. end
Add Comment
Please, Sign In to add comment