Advertisement
Ratufufu

[Transformice] Collect XML

Apr 28th, 2024
858
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.35 KB | None | 0 0
  1. local admin = debug.traceback():match('%w-#%d+')
  2.  
  3. for _,d in next, {'AfkDeath','AutoNewGame','AutoShaman'} do
  4.     tfm.exec['disable'..d]()
  5. end
  6.  
  7. system.bindKeyboard(admin,32,true,true)
  8.  
  9. system.disableChatCommandDisplay()
  10.  
  11. local xml,author,code
  12.  
  13. eventNewGame = function()
  14.     table.foreach(tfm.get.room.playerList, function(k,v) tfm.exec.setPlayerNightMode(false,k) end)
  15.     if tfm.get.room.xmlMapInfo then
  16.         code = tfm.get.room.xmlMapInfo.mapCode
  17.         author = tfm.get.room.xmlMapInfo.author
  18.         xml = tfm.get.room.xmlMapInfo.xml
  19.        
  20.         ui.setMapName('<J>'..author..'</J><BL> - @'..code..'</BL>')
  21.     else
  22.         xml = nil
  23.     end
  24.     tfm.get.room.xmlMapInfo = nil
  25. end
  26.  
  27. eventChatCommand = function(name,cmd)
  28.     if name == admin then
  29.         local p = {}
  30.         for w in cmd:gmatch('[^%s]+') do
  31.             p[#p + 1] = w
  32.         end
  33.        
  34.         if p[1] == 'map' or p[1] == 'np' then
  35.             local map = p[2] and p[2]:match('[@#]%d+') or '@0'
  36.             tfm.exec.newGame(map)
  37.         end
  38.     end
  39. end
  40.  
  41. eventKeyboard = function(name,_,p)
  42.     if xml then
  43.         print(xml:gsub('<','&lt;'))
  44.     end
  45. end
  46.  
  47. eventPlayerDied = function(name)
  48.   tfm.exec.setPlayerNightMode(false,name)
  49.   tfm.exec.respawnPlayer(name)
  50. end
  51. eventNewPlayer = function(name)
  52.   tfm.exec.setPlayerNightMode(false,name)
  53.   tfm.exec.respawnPlayer(name)
  54. end
  55. eventPlayerWon = function(name)
  56.   tfm.exec.setPlayerNightMode(false,name)
  57.   tfm.exec.respawnPlayer(name)
  58. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement