Advertisement
superpaste

paint battle lua tfm

Apr 10th, 2017
548
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 15.74 KB | None | 0 0
  1. contains = function(t,v)
  2.     for k,v1 in pairs(v) do
  3.         if v1==v then
  4.             return true
  5.         end
  6.     end
  7. end
  8.  
  9. trans={pt={COLOR_SELECT="Seleciona a cor!",CALL_THEME="o tema é ",WAITING="Número insuficiente de ratos",VOTING_START="Tema feita por ",START_VOTING="O tempo acabou... Todos os ratos irão votar todas as pinturas",OPTION_SELECTOR="(Podes selecionar a cor clicando em espaço"},en={COLOR_SELECT="Seleciona a cor!",CALL_THEME="theme is ",START_VOTING="Theme by ",WAITING="Insuficient number of players",OPTION_SELECTOR="(you can select the color using space)",VOTING_START="Time is over, all will vote all pictures"}}
  10. lang = "EN" --CHOOOOSEEEE THE LANGUAGE HERE!!!!!!
  11. if contains(tfm.get.room.community,trans) then
  12.     lang = tfm.get.room.community
  13. end
  14. roomLanguage = trans[lang]
  15. print(tfm.get.room.community)
  16.  
  17.  
  18. timePerRound=120
  19. tfm.exec.newGame('<C><P G="0,1" /><Z><S><S L="800" H="63" X="401" Y="414" T="6" P="0,0,0.3,0.2,0,0,0,0" /><S L="20" o="fff500" H="100" X="508" Y="239" T="12" P="0,0,0.3,0.2,60,0,0,0" /><S L="148" o="935900" H="29" X="386" Y="223" T="12" P="0,0,0.3,0.2,45,0,0,0" /><S L="28" o="935900" H="10" X="333" Y="170" T="13" P="0,0,0.3,0.2,0,0,0,0" /><S L="20" o="324650" H="20" X="467" Y="263" T="12" P="0,0,0.3,0.2,0,0,0,0" /><S L="58" o="fff500" H="10" X="472" Y="270" T="12" P="0,0,0.3,0.2,-45,0,0,0" /><S P="0,0,0.3,0.2,40,0,0,0" L="148" o="935900" X="380" Y="227" T="12" H="29" /><S L="50" o="324650" H="10" X="466" Y="257" T="12" P="0,0,0.3,0.2,-15,0,0,0" /><S L="20" o="324650" H="10" X="444" Y="276" T="13" P="0,0,0.3,0.2,0,0,0,0" /><S L="148" o="935900" X="391" H="29" Y="217" T="12" P="0,0,0.3,0.2,50,0,0,0" /><S P="0,0,0.3,0.2,-50,0,0,0" L="58" o="324650" X="472" Y="269" T="12" H="10" /><S L="27" o="fff500" H="188" X="544" Y="129" T="12" P="0,0,0.3,0.2,0,0,0,0" /></S><D /><O /></Z></C>')
  20. paint = 2
  21. step = "remove"
  22. tfm.exec.setGameTime(5, true)
  23. function remove()
  24.     for i = 2, paint do
  25.         ui.removeTextArea(i, nil)
  26.     end
  27. end
  28. points = {}
  29. pos = {}
  30. people = {}
  31. mor = {}
  32. choosed = {}
  33. size = {}
  34. function create()
  35.     points = {}
  36.     pos = {}
  37.     people = {}
  38.     mor = {}
  39.     choosed = {}
  40.     size = {}
  41.     tfm.exec.newGame('<C><P L="8800" Ca="" /><Z><S /><D /><O /></Z></C>', nil)
  42.     number = 1
  43.     for i, v in pairs(tfm.get.room.playerList) do
  44.         tfm.exec.addPhysicObject(number*5-4, number*900, 200,{type=12, width=800, height=400, color=0xffffff,miceCollision=false,foreground=true})
  45.         tfm.exec.addPhysicObject(number*5-3, number*900, 300,{type=0, width=100, height=10})
  46.         tfm.exec.addPhysicObject(number*5-2, number*900, 250,{type=0, width=100, height=10})
  47.         tfm.exec.addPhysicObject(number*5-1, number*900+20, 250,{type=0, width=10, height=100})
  48.         tfm.exec.addPhysicObject(number*5, number*900-20, 250,{type=0, width=10, height=100})
  49.         tfm.exec.movePlayer(i, number*900, 300, false, 0, 0, false)
  50.         pos[i] = number
  51.         points[i] = 0
  52.         table.insert(people, i)
  53.         choosed[i] = "NaN"
  54.         number = number + 1
  55.         size[i] = 5
  56.     end
  57.     tfm.exec.setGameTime(10, true)
  58.     words = {"monkey", "car", "jelly", "piano", "flower", "pot"}
  59.     no = math.random(#words)
  60.     oneoption = words[no]
  61.    
  62.     no = math.random(#words)
  63.     twooption = words[no]
  64.    
  65.     no = math.random(#words)
  66.     threeoption = words[no]
  67.    
  68.    
  69.     no = math.random(#words)
  70.     fouroption = words[no]
  71.    
  72.    
  73.     onechoose = 0
  74.     twochoose = 0
  75.     threechoose = 0
  76.     fourchoose = 0
  77.     step = "choosing"
  78.    
  79.     ui.addTextArea(1, '<a href="event:oneoption">' .. tostring(oneoption) .. '</a>', nil, 200, 200, 100, 0, 0x123450, 0x123450, 1, true)
  80.     ui.addTextArea(2, '<a href="event:twooption">' .. tostring(twooption) .. '</a>', nil, 200, 250, 100, 0, 0x123450, 0x123450, 1, true)
  81.     ui.addTextArea(3, '<a href="event:threeoption">' .. tostring(threeoption) .. '</a>', nil, 200, 300, 100, 0, 0x123450, 0x123450, 1, true)
  82.     ui.addTextArea(4, '<a href="event:fouroption">' .. tostring(fouroption) .. '</a>', nil, 200, 350, 100, 0, 0x123450, 0x123450, 1, true)
  83.    
  84.     for i, v in pairs(pos) do
  85.         print(i .. " " .. v)
  86.     end
  87. end
  88. tfm.exec.disableMortCommand(true)
  89. tfm.exec.disableAfkDeath(true)
  90. tfm.exec.disableAutoNewGame(true)
  91. tfm.exec.disableAutoScore(true)
  92. tfm.exec.disableAutoTimeLeft(true)
  93. tfm.exec.disableAutoShaman(true)
  94.  
  95. function eventTextAreaCallback(id, j, call)
  96.     -- aq fica tudo sobre escolher a palavra
  97.     if step == "choosing" then
  98.         if call == "oneoption" and not(choosed[j] == "oneoption") then
  99.             if choosed[j] == "twooption" then
  100.                 twochoose = twochoose - 1
  101.             end
  102.             if choosed[j] == "threeoption" then
  103.                 threechoose = threechoose - 1
  104.             end
  105.             if choosed[j] == "fouroption" then
  106.                 fourchoose = fourchoose - 1
  107.             end
  108.             choosed[j] = "oneoption"
  109.             ui.addTextArea(1, '<a href="event:oneoption">' .. tostring(oneoption) .. '</a>', nil, 200, 200, 100, 0, 0x123450, 0xCCFFC, 1, true)
  110.             ui.addTextArea(2, '<a href="event:twooption">' .. tostring(twooption) .. '</a>', nil, 200, 250, 100, 0, 0x123450, 0x123450, 1, true)
  111.             ui.addTextArea(3, '<a href="event:threeoption">' .. tostring(threeoption) .. '</a>', nil, 200, 300, 100, 0, 0x123450, 0x123450, 1, true)
  112.             ui.addTextArea(4, '<a href="event:fouroption">' .. tostring(fouroption) .. '</a>', nil, 200, 350, 100, 0, 0x123450, 0x123450, 1, true)
  113.             onechoose = onechoose + 1
  114.         end
  115.         if call == "twooption" and not(choosed[j] == "twooption") then
  116.             if choosed[j] == "oneoption" then
  117.                 onechoose = onechoose - 1
  118.             end
  119.             if choosed[j] == "threeoption" then
  120.                 threechoose = threechoose - 1
  121.             end
  122.             if choosed[j] == "fouroption" then
  123.                 fourchoose = fourchoose - 1
  124.             end
  125.             choosed[j] = "twooption"
  126.             ui.addTextArea(1, '<a href="event:oneoption">' .. tostring(oneoption) .. '</a>', j, 200, 200, 100, 0, 0x123450, 0x123450, 1, true)
  127.             ui.addTextArea(2, '<a href="event:twooption">' .. tostring(twooption) .. '</a>', j, 200, 250, 100, 0, 0x123450, 0xCCFFC, 1, true)
  128.             ui.addTextArea(3, '<a href="event:threeoption">' .. tostring(threeoption) .. '</a>', j, 200, 300, 100, 0, 0x123450, 0x123450, 1, true)
  129.             ui.addTextArea(4, '<a href="event:fouroption">' .. tostring(fouroption) .. '</a>', j, 200, 350, 100, 0, 0x123450, 0x123450, 1, true)
  130.             twochoose = twochoose + 1
  131.         end
  132.         if call == "threeoption" and not(choosed[j] == "threeoption") then
  133.             if choosed[j] == "oneoption" then
  134.                 onechoose = onechoose - 1
  135.             end
  136.             if choosed[j] == "twooption" then
  137.                 twochoose = twochoose - 1
  138.             end
  139.             if choosed[j] == "fouroption" then
  140.                 fourchoose = fourchoose - 1
  141.             end
  142.             choosed[j] = "threeoption"
  143.             ui.addTextArea(1, '<a href="event:oneoption">' .. tostring(oneoption) .. '</a>', j, 200, 200, 100, 0, 0x123450, 0x123450, 1, true)
  144.             ui.addTextArea(2, '<a href="event:twooption">' .. tostring(twooption) .. '</a>', j, 200, 250, 100, 0, 0x123450, 0x123450, 1, true)
  145.             ui.addTextArea(3, '<a href="event:threeoption">' .. tostring(threeoption) .. '</a>', j, 200, 300, 100, 0, 0x123450, 0xCCFFC, 1, true)
  146.             ui.addTextArea(4, '<a href="event:fouroption">' .. tostring(fouroption) .. '</a>', j, 200, 350, 100, 0, 0x123450, 0x123450, 1, true)
  147.             threechoose = threechoose + 1
  148.         end
  149.         if call == "fouroption" and not(choosed[j] == "fouroption") then
  150.             if choosed[j] == "oneoption" then
  151.                 onechoose = onechoose - 1
  152.             end
  153.             if choosed[j] == "twooption" then
  154.                 twochoose = twochoose - 1
  155.             end
  156.             if choosed[j] == "threeoption" then
  157.                 threechoose = threechoose - 1
  158.             end
  159.             choosed[j] = "fouroption"
  160.             ui.addTextArea(1, '<a href="event:oneoption">' .. tostring(oneoption) .. '</a>', j, 200, 200, 100, 0, 0x123450, 0x123450, 1, true)
  161.             ui.addTextArea(2, '<a href="event:twooption">' .. tostring(twooption) .. '</a>', j, 200, 250, 100, 0, 0x123450, 0x123450, 1, true)
  162.             ui.addTextArea(3, '<a href="event:threeoption">' .. tostring(threeoption) .. '</a>', j, 200, 300, 100, 0, 0x123450, 0x123450, 1, true)
  163.             ui.addTextArea(4, '<a href="event:fouroption">' .. tostring(fouroption) .. '</a>', j, 200, 350, 100, 0, 0x123450, 0xCCFFC, 1, true)
  164.             fourchoose = fourchoose + 1
  165.         end
  166.         ui.updateTextArea(1, '<a href="event:oneoption">' .. tostring(oneoption) .. '</a>' .. " " .. onechoose, nil)
  167.         ui.updateTextArea(2, '<a href="event:twooption">' .. tostring(twooption) .. '</a>' .. " " .. twochoose, nil)
  168.         ui.updateTextArea(3, '<a href="event:threeoption">' .. tostring(threeoption) .. '</a>' .. " " .. threechoose, nil)
  169.         ui.updateTextArea(4, '<a href="event:fouroption">' .. tostring(fouroption) .. '</a>' .. " " .. fourchoose, nil)
  170.        
  171.         else
  172.         if call == "color" then
  173.             ui.removeTextArea(0, j)
  174.             ui.showColorPicker(1, j, color[j], "select the color")
  175.             system.bindMouse(j, true)
  176.         end
  177.         player=j
  178.         if call == "more" then
  179.             if not(contains(player, mor)) then
  180.                 mor[#mor+1]=player
  181.                 if #mor >= math.ceil(#people / 2) then
  182.                     tfm.exec.setGameTime(timePerRound, true)
  183.                 end
  184.             end
  185.         end
  186.         if call == "paper" then
  187.             ui.removeTextArea(0, j)
  188.             ui.showColorPicker(2, j, 0x000000, "select the color of the paper (NOT WORKING)")
  189.             system.bindMouse(j, true)
  190.         end
  191.         if call == "size" then
  192.             ui.removeTextArea(0, j)
  193.             ui.addPopup(1, 2, "input here the size", j, 300, 200, 200, true)
  194.             system.bindMouse(j, true)
  195.         end
  196.         if call == "Super poop" then
  197.             points[people[now]] = points[people[now]] + 1
  198.             ui.removeTextArea(1, j)
  199.         end
  200.         if call == "poop" then
  201.             points[people[now]] = points[people[now]] + 2
  202.             ui.removeTextArea(1, j)
  203.         end
  204.         if call == "ok" then
  205.             points[people[now]] = points[people[now]] + 3
  206.             ui.removeTextArea(1, j)
  207.         end
  208.         if call == "good" then
  209.             points[people[now]] = points[people[now]] + 4
  210.             ui.removeTextArea(1, j)
  211.         end
  212.         if call == "epic" then
  213.             points[people[now]] = points[people[now]] + 5
  214.             ui.removeTextArea(1, j)
  215.         end
  216.         if call == "legendary" then
  217.             points[people[now]] = points[people[now]] + 6
  218.             ui.removeTextArea(1, j)
  219.             ui.addTextArea(1, '<J><p align="center">LEGENDARY!!!!!</p>', people[now], 0, 380, 800, 0, 0x123455, 0x123450, 1, true)
  220.            
  221.         end
  222.     end
  223. end
  224.  
  225.  
  226. function eventLoop(p, r) --agr que vi o eventLoop() é o maior 0.0
  227.     print(mor)
  228.     if r < 0 then
  229.         if step == "choosing" then
  230.             choos = false
  231.             what = ""
  232.             if onechoose > twochoose and onechoose > threechoose and onechoose > fourchoose then
  233.                 print(oneoption)
  234.                 choos = true
  235.                 what = oneoption
  236.             end
  237.             if twochoose > onechoose and twochoose > threechoose and twochoose > fourchoose then
  238.                 print(twooption)
  239.                 choos = true
  240.                 what = twooption
  241.             end
  242.             if threechoose > onechoose and threechoose > twochoose and threechoose > fourchoose then
  243.                 print(threeoption)
  244.                 choos = true
  245.                 what = threeoption
  246.             end
  247.             if fourchoose > onechoose and fourchoose > twochoose and fourchoose > threechoose then
  248.                 print(fouroption)
  249.                 choos = true
  250.                 what = fouroption
  251.             end
  252.             if choos then
  253.                 step = "draw"
  254.                 ui.removeTextArea(1, nil)
  255.                 ui.removeTextArea(2, nil)
  256.                 ui.removeTextArea(3, nil)
  257.                 ui.removeTextArea(4, nil)
  258.                 ui.addTextArea(1, '<p align="center">' .. roomLanguage["CALL_THEME"] .. what .. roomLanguage["OPTION_SELECTOR"] .. '</p>', nil, 0, 380, 800, 0, 0x123450, 0x123450, 0.8, true)
  259.                 paint = 2
  260.                 tfm.exec.setGameTime(timePerRound, true)
  261.                 color = {}
  262.                 size = {}
  263.                 for i, v in pairs(tfm.get.room.playerList) do
  264.                     system.bindMouse(i, true)
  265.                     system.bindKeyboard(i, 32, false, true)
  266.                     color[i] = 0x000000
  267.                     size[i] = 5
  268.                 end
  269.             end
  270.             elseif step == "draw" then
  271.             for i, v in pairs(tfm.get.room.playerList) do
  272.                 system.bindMouse(i, false)
  273.             end
  274.             ui.removeTextArea(1, nil)
  275.             ui.addTextArea(1, '<p align="center">' .. roomLanguage["START_VOTING"] .. '</p>' , nil, 0, 200, 800, 0, 0x123455, 0x123450, 1, true)
  276.             step = "start vote"
  277.             tfm.exec.setGameTime(3, true)
  278.             elseif step == "start vote" then
  279.             now = 1
  280.             for i, v in pairs(tfm.get.room.playerList) do
  281.                 print(people[now])
  282.                 tfm.exec.movePlayer(i, pos[people[now]]*900, 300, false, 0, 0, false)
  283.             end
  284.             ui.addTextArea(1, '<p align="center">' .. roomLanguage["VOTING_START"] .. people[now] .. ' <a href="event:Super poop">Super poop</a>, <a href="event:poop">poop</a>, <a href="event:ok">ok</a>, <a href="event:good">good</a>, <a href="event:epic">epic</a> or <a href="event:legendary">LEGENDARY</a></p>', nil, 0, 380, 800, 0, 0x123455, 0x123450, 1, true)
  285.             ui.addTextArea(1, '<p align="center">Your picture</p>', people[now], 0, 380, 800, 0, 0x123455, 0x123450, 1, true)
  286.             step = "voting"
  287.             tfm.exec.setGameTime(10, true)
  288.             elseif step == "voting" then
  289.             now = now + 1
  290.             if now == #people + 1 then
  291.                 step = "collecting"
  292.                 tfm.exec.setGameTime(10, true)
  293.                 else
  294.                 points[people[now]] = 0
  295.                 for i, v in pairs(tfm.get.room.playerList) do
  296.                     print(people[now])
  297.                     tfm.exec.movePlayer(i, pos[people[now]]*900, 300, false, 0, 0, false)
  298.                 end
  299.                 ui.addTextArea(1, '<p align="center">' .. roomLanguage["VOTING_START"] .. people[now] .. ' <a href="event:Super poop">Super poop</a>, <a href="event:poop">poop</a>, <a href="event:ok">ok</a>, <a href="event:good">good</a>, <a href="event:epic">epic</a> or <a href="event:legendary">LEGENDARY</a></p>', nil, 0, 380, 800, 0, 0x123455, 0x123450, 1, true)
  300.                 ui.addTextArea(1, '<p align="center">Your picture</p>', people[now], 0, 380, 800, 0, 0x123455, 0x123450, 1, true)
  301.             end
  302.             tfm.exec.setGameTime(10, true)
  303.             elseif step == "collecting" then
  304.             that = ""
  305.             pointed = -1
  306.             for i, v in pairs(points) do
  307.                 tfm.exec.setPlayerScore(i, v, false)
  308.                 if v > pointed then
  309.                     pointed = v
  310.                     that = i
  311.                 end
  312.             end
  313.             for i, v in pairs(tfm.get.room.playerList) do
  314.                 tfm.exec.movePlayer(i, pos[that]*900, 300, false, 0, 0, false)
  315.             end
  316.             ui.addTextArea(1, '<p align="center">' .. that .. ' wins!</p>', nil, 0, 200, 800, 0, 0x123455, 0x123450, 1, true)
  317.             step = "remove"
  318.             tfm.exec.setGameTime(5, true)
  319.             elseif step == "remove" then
  320.             people = 0
  321. roomPeoplePlaying=0
  322.             for i, v in pairs(tfm.get.room.playerList) do
  323.                 people = people + 1
  324. roomPeoplePlaying=roomPeoplePlaying+1
  325.             end
  326.             if people > 1 then
  327.                 remove()
  328.                 create()
  329.                 else
  330.                 ui.addTextArea(1, '<p align="center">'..roomLanguage["WAITING"]..'</p>', nil, 0, 200, 800, 0, 0x123455, 0x123450, 1, true)
  331.             end
  332.         end
  333.     end
  334.     if not(r<0) then
  335.         if step=="collecting" then
  336.             for i, v in pairs(tfm.get.room.playerList) do
  337.                 print(pos[people[math.random(0,roomPeoplePlaying-1)]])
  338. print(people[math.random(1,roomPeoplePlaying)])
  339. print(roomPeoplePlaying)
  340.                 tfm.exec.movePlayer(i, pos[people[math.random(1,roomPeoplePlaying)]]*900, 300, false, 0, 0, false)
  341.                 ui.addTextArea(1, '<p align="center">Who will win?</p>', nil, 0, 200, 800, 0, 0x123455, 0x123450, 1, true)
  342.             end
  343.         end
  344.     end
  345. end
  346.  
  347. function eventMouse(j, x, y)
  348.     if step == "draw" then
  349.         if pos[j]*900-400 < x and pos[j]*900+400 > x then -- assetar as bordas
  350.             --o addTextArea em baixo é a coisa mais importante, obviamente no paint battle tem que haver pintura
  351.             ui.addTextArea(paint, "", nil, x - size[j]/2, y - size[j]/2, size[j], size[j], color[j], color[j], 1, false)
  352.             paint = paint + 1
  353.         end
  354.     end
  355. end
  356.  
  357. function eventKeyboard(j, id, p, x, y)
  358.     system.bindMouse(j, false)
  359.     ui.addTextArea(0, '<a href="event:color">select the color!</a><br/><a href="event:size">select the size!</a><br/><a href="event:paper">Change the color of the background</a><br/><a href="event:more">More time!</a>', j, 0, 180, 800, 0, 0x123450, 0x123450, 1, true)
  360. end
  361.  
  362. function eventColorPicked(id, j, c)
  363.     if not(tonumber(c) == -1) and not(tonumber(c)==nil) then
  364.         if id == 1 then
  365.             color[j] = tonumber(c)
  366.             ui.addTextArea(1, '<p align="center">'.. roomLanguage["CALL_THEME"] .. what .. '</p>', j, 0, 380, 800, 0, color[j], 0x123450, 0.8, true)
  367.         end
  368.         if id == 3 then
  369.             tfm.exec.removePhysicObject(pos[j]*5-4)
  370.             tfm.exec.addPhysicObject(pos[j]*5-4, pos[j]*900, 200,{type=12, width=800, height=400, color=0xffffff,miceCollision=false,foreground=true})
  371.         end
  372.     end
  373. end
  374.  
  375. function eventPopupAnswer(id, j, r)
  376.     if id == 1 and not(tonumber(r)==nil) then
  377.         size[j] = tonumber(r)
  378.     end
  379. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement