Advertisement
Guest User

Paintwar Map Editor - Transformice Lua

a guest
Sep 6th, 2014
266
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 8.70 KB | None | 0 0
  1. base = "123456789abcdefghijklmnopqrstuvwxyzABCDEFGIJKLMNOPQRSTUVWXYZ"
  2. code = "@5313671"
  3. adm = "Ninguem" -- mude para seu nick
  4. change = false
  5. op = -1
  6. mirrorX = false
  7. mirrorY = false
  8. grid = true
  9. help = false
  10. idSelect = 1
  11. idMirror = 2
  12. idGrid = 3
  13. idGridText = 4
  14. idGridOff = 6
  15. idHelp = 7
  16. idHelpText = 8
  17. idSaveText = 9
  18. idExitText = 10
  19. idInfo = 11
  20. popDelete = 12
  21. popSave = 13
  22. popExit = 14
  23. contObject = 0
  24. contGround = 0
  25. contVamp = 0
  26. contDeath = 0
  27. contScore = 0
  28. contSpawn = 0
  29. ground = {type=0,height=16,width=16,color=0,foreground=true}
  30. layer = {type=12,height=320,width=640,color=0x6a7495}
  31. map = {}
  32. for i = 1, 20 do
  33.     map[i] = {}
  34.     for j = 1, 40 do
  35.         map[i][j] = -1
  36.     end
  37. end
  38.  
  39. tfm.exec.disableAfkDeath(true)
  40. tfm.exec.disableAutoNewGame(true)
  41. tfm.exec.disableAutoShaman(true)
  42. tfm.exec.newGame(code)
  43.  
  44. function cont()
  45.     local warnObject = ""
  46.     local warnGround = ""
  47.     local warnScore = ""
  48.     local warnSpawn = ""
  49.     contObject = 0
  50.     contGround = 0
  51.     contVamp = 0
  52.     contDeath = 0
  53.     contScore = 0
  54.     contSpawn = 0
  55.     for i = 1, 20 do
  56.         for j = 1, 40 do
  57.             if map[i][j] ~= -1 then
  58.                 contObject = contObject + 1
  59.                 if map[i][j] >= 0 and map[i][j] <= 8 then
  60.                     contGround = contGround + 1
  61.                 elseif map[i][j] == 10 then
  62.                     contVamp = contVamp + 1
  63.                 elseif map[i][j] == 11 then
  64.                     contDeath = contDeath + 1
  65.                 elseif map[i][j] == 12 then
  66.                     contScore = contScore + 1
  67.                 elseif map[i][j] == 13 then
  68.                     contSpawn = contSpawn + 1
  69.                 end
  70.             end
  71.         end
  72.     end
  73.     if contObject == 0 or contObject > 400 then
  74.         warnObject = "<r>"
  75.     end
  76.     if contGround == 0 then
  77.         warnGround = "<r>"
  78.     end
  79.     if contScore == 0 then
  80.         warnScore = "<r>"
  81.     end
  82.     if contSpawn == 0 then
  83.         warnSpawn = "<r>"
  84.     end
  85.     local info = warnObject.."Objects: "..contObject.."/400\n<n>"..warnGround.."Grounds: "..contGround.."\n<n>Item points: "..contVamp.."\nDeath points: "..contDeath.."\n<n>"..warnScore.."Score points: "..contScore.."\n<n>"..warnSpawn.."Spawn points: "..contSpawn
  86.     ui.addTextArea(idInfo, info, nil, 660, 90, 130, 100, 0, 0, 0, false)
  87. end
  88.  
  89. function generate()
  90.     local text = string.format("%03d", contObject)
  91.     for i = 1, 20 do
  92.         for j = 1, 40 do
  93.             if map[i][j] ~= -1 then
  94.                 text = text .. base:sub(i,i) .. base:sub(j,j) .. base:sub(map[i][j]+1,map[i][j]+1)
  95.             end
  96.         end
  97.     end
  98.     print("<j>Paste this XML in Tansformice Map Editor and Export as tribe house.\n<n>&lt;<font size='6px'>\n"..[[C&gt;&lt;P Ca=""H="800"L="1600"Pw="]]..text..[["/&gt;&lt;Z&gt;&lt;S/&gt;&lt;D/&gt;&lt;O/&gt;&lt;/Z&gt;&lt;/C]].."\n</font>&gt;")
  99.     tfm.exec.chatMessage("<j>Paste this XML in Tansformice Map Editor and Export as tribe house.\n<n>&lt;<font size='6px'>\n"..[[C&gt;&lt;P Ca=""H="800"L="1600"Pw="]]..text..[["/&gt;&lt;Z&gt;&lt;S/&gt;&lt;D/&gt;&lt;O/&gt;&lt;/Z&gt;&lt;/C]].."\n</font>&gt;", adm)
  100. end
  101.  
  102. function makeGround(x, y, op)
  103.     tfm.exec.addPhysicObject(x*100+y, x*16+2, y*16+22, ground)
  104.     map[y][x] = op
  105. end
  106.  
  107. function eventNewGame()
  108.     change = true
  109.     tfm.exec.setUIMapName("Editor - " .. adm .. "\n")
  110.     ui.addTextArea(idSelect, "", nil, 55, 360, 30, 30, 0, 0xffff00, 0.3, false)
  111.     ui.addTextArea(idMirror, "", nil, 495, 360, 30, 30, 0, 0x0000ff, 0.3, false)
  112.     ui.addTextArea(idInfo, "<r>Objects: 0/400\nGrounds: 0\n<n>Item points: 0\nDeath points: 0\n<r>Score points: 0\nSpawn points: 0", nil, 660, 90, 130, 100, 0, 0, 0, false)
  113.     ui.addTextArea(idGridText, "<p align='center'><font color='#0'><b>Show grid", nil, 660, 30, 130, 20, 0, 0, 0, false)
  114.     ui.addTextArea(idGrid, "", nil, 660, 30, 130, 20, 0, 1, 0.3, false)
  115.     ui.addTextArea(idHelpText, "<p align='center'><font color='#0'><b>Helper friend", nil, 660, 60, 130, 20, 0, 0, 0, false)
  116.     ui.addTextArea(idSaveText, "<p align='center'><font color='#0'><b>Export XML", nil, 660, 345, 130, 20, 0, 0, 0, false)
  117.     ui.addTextArea(idExitText, "<p align='center'><font color='#0'><b>Exit the editor", nil, 660, 375, 130, 20, 0, 0, 0, false)
  118.     for i, v in pairs(tfm.get.room.playerList) do
  119.         system.bindMouse(i, true)
  120.         if i ~= adm then
  121.             tfm.exec.killPlayer(i)
  122.         end
  123.     end
  124. end
  125.  
  126. function eventPopupAnswer(popup, p, a)
  127.     if popup == popDelete and a == "yes" then
  128.         for i = 1, 20 do
  129.             for j = 1, 40 do
  130.                 map[i][j] = -1
  131.                 tfm.exec.removePhysicObject(j*100+i)
  132.             end
  133.         end
  134.         cont()
  135.     elseif popup == popSave and a == "yes" then
  136.         generate()
  137.     elseif popup == popExit and a == "yes" then
  138.         system.exit()
  139.     end
  140. end
  141.  
  142. function eventMouse(p, x, y)
  143.     if p == adm then
  144.         if x > 10 and x < 650 and y > 30 and y < 350 then
  145.             local xx = math.floor((x-10)/16)+1
  146.             local yy = math.floor((y-30)/16)+1
  147.             if op == -1 then
  148.                 tfm.exec.removePhysicObject(xx*100+yy)
  149.                 map[yy][xx] = op
  150.             elseif contObject <= 400 then
  151.                 if op >= 0 and op <= 8 then
  152.                     ground.type = op
  153.                     ground.width = 16
  154.                     ground.height = 16
  155.                 else
  156.                     ground.width = 10
  157.                     ground.height = 10
  158.                     ground.type = 12
  159.                     if op == 10 then
  160.                         ground.color = 0xFFC300
  161.                     elseif op == 11 then
  162.                         ground.color = 0xF93801
  163.                     elseif op == 12 then
  164.                         ground.color = 0xFF00DC
  165.                     elseif op == 13 then
  166.                         ground.color = 0x78583A
  167.                     end
  168.                 end
  169.                 makeGround(xx, yy, op)
  170.                 if mirrorX then
  171.                     makeGround(41-xx, yy, op)
  172.                 end
  173.                 if mirrorY then
  174.                     makeGround(xx, 21-yy, op)
  175.                 end
  176.                 if mirrorY and mirrorX then
  177.                     makeGround(41-xx, 21-yy, op)
  178.                 end
  179.             end
  180.         elseif x > 660 and x < 790 then
  181.             if y > 30 and y < 50 then
  182.                 if grid then
  183.                     grid = false
  184.                     ui.removeTextArea(idGrid, nil)
  185.                     tfm.exec.addPhysicObject(idGridOff, 330, 190, layer)
  186.                 else
  187.                     grid = true
  188.                     ui.addTextArea(idGrid, "", nil, 660, 30, 130, 20, 0, 1, 0.3, false)
  189.                     tfm.exec.removePhysicObject(idGridOff)
  190.                 end
  191.             elseif y > 60 and y < 80 then
  192.                 if help then
  193.                     help = false
  194.                     ui.removeTextArea(idHelp, nil)
  195.                 else
  196.                     help = true
  197.                     ui.addTextArea(idHelp, "", nil, 660, 60, 130, 20, 0, 1, 0.3, false)
  198.                 end
  199.             elseif y > 340 and y < 370 then
  200.                 if contObject <= 400 and contGround > 0 and contScore > 0 and contSpawn > 0 then
  201.                     ui.addPopup(popSave, 1, "<p align='center'>Ready for the flood?", adm, 250, 200, 300, true)
  202.                 else
  203.                     ui.addPopup(popSave, 0, "<p align='center'>The map can't be so. Look the informations in red.", adm, 250, 200, 300, true)
  204.                 end
  205.             elseif y > 370 and y < 400 then
  206.                 ui.addPopup(popExit, 1, "<p align='center'>Exit the editor?", adm, 250, 200, 300, true)
  207.             end
  208.         elseif y > 360 and y < 390 then
  209.             if x > 15 and x < 45 then
  210.                 ui.addPopup(popDelete, 1, "<p align='center'>Delete all objects?", adm, 250, 200, 300, true)
  211.             elseif x > 55 and x < 85 then
  212.                 ui.addTextArea(idSelect, "", nil, 55, 360, 30, 30, 0, 0xffff00, 0.3, false)
  213.                 op = -1
  214.             elseif x > 95 and x < 125 then
  215.                 ui.addTextArea(idSelect, "", nil, 95, 360, 30, 30, 0, 0xffff00, 0.3, false)
  216.                 op = 0
  217.             elseif x > 135 and x < 165 then
  218.                 ui.addTextArea(idSelect, "", nil, 135, 360, 30, 30, 0, 0xffff00, 0.3, false)
  219.                 op = 1
  220.             elseif x > 175 and x < 205 then
  221.                 ui.addTextArea(idSelect, "", nil, 175, 360, 30, 30, 0, 0xffff00, 0.3, false)
  222.                 op = 2
  223.             elseif x > 215 and x < 245 then
  224.                 ui.addTextArea(idSelect, "", nil, 215, 360, 30, 30, 0, 0xffff00, 0.3, false)
  225.                 op = 3
  226.             elseif x > 255 and x < 285 then
  227.                 ui.addTextArea(idSelect, "", nil, 255, 360, 30, 30, 0, 0xffff00, 0.3, false)
  228.                 op = 4
  229.             elseif x > 295 and x < 325 then
  230.                 ui.addTextArea(idSelect, "", nil, 295, 360, 30, 30, 0, 0xffff00, 0.3, false)
  231.                 op = 8
  232.             elseif x > 335 and x < 365 then
  233.                 ui.addTextArea(idSelect, "", nil, 335, 360, 30, 30, 0, 0xffff00, 0.3, false)
  234.                 op = 10
  235.             elseif x > 375 and x < 405 then
  236.                 ui.addTextArea(idSelect, "", nil, 375, 360, 30, 30, 0, 0xffff00, 0.3, false)
  237.                 op = 11
  238.             elseif x > 415 and x < 445 then
  239.                 ui.addTextArea(idSelect, "", nil, 415, 360, 30, 30, 0, 0xffff00, 0.3, false)
  240.                 op = 12
  241.             elseif x > 455 and x < 485 then
  242.                 ui.addTextArea(idSelect, "", nil, 455, 360, 30, 30, 0, 0xffff00, 0.3, false)
  243.                 op = 13
  244.             elseif x > 495 and x < 525 then
  245.                 ui.addTextArea(idMirror, "", nil, 495, 360, 30, 30, 0, 0x0000ff, 0.3, false)
  246.                 mirrorX = false
  247.                 mirrorY = false
  248.             elseif x > 535 and x < 565 then
  249.                 ui.addTextArea(idMirror, "", nil, 535, 360, 30, 30, 0, 0x0000ff, 0.3, false)
  250.                 mirrorX = true
  251.                 mirrorY = false
  252.             elseif x > 575 and x < 605 then
  253.                 ui.addTextArea(idMirror, "", nil, 575, 360, 30, 30, 0, 0x0000ff, 0.3, false)
  254.                 mirrorX = false
  255.                 mirrorY = true
  256.             elseif x > 615 and x < 645 then
  257.                 ui.addTextArea(idMirror, "", nil, 615, 360, 30, 30, 0, 0x0000ff, 0.3, false)
  258.                 mirrorX = true
  259.                 mirrorY = true
  260.             end
  261.         end
  262.         cont()
  263.     elseif help then
  264.         tfm.exec.displayParticle(0, x, y, 0, 0, 0, 0, nil)
  265.     end
  266. end
  267.  
  268. function eventLoop(current,remaining)
  269.     if not change then
  270.         tfm.exec.newGame(code)
  271.     end
  272. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement