Advertisement
superpaste

votaçoes

Oct 12th, 2017
162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.85 KB | None | 0 0
  1. tfm.exec.disableAutoNewGame(true)
  2. tfm.exec.disableAutoTimeLeft(true)
  3. tfm.exec.disableAfkDeath(true)
  4. options={"drawbattle","batata","braço que gira","braço que n gira"}
  5.  
  6.  
  7.  
  8.  
  9.  
  10.  
  11.  
  12. -------------------------------
  13. tfm.exec.newGame('<C><P /><Z><S /><D><DS Y="-100" X="400" /></D><O /></Z></C>')
  14. votes={}
  15. parent={}
  16. if #options==0 then
  17.     print('<R>ERROR:</R> <font color="#ffffff">no options </font>')
  18.     elseif #options==1 then
  19.     print('<R>ERROR:</R> <font color="#ffffff">1 option for?</font>')
  20.     else
  21.     uis=0
  22.     for _,i in pairs(options) do
  23.         votes[i]={}
  24.         parent[uis]=i
  25.         randomized=math.random(50,200)
  26.         ui.addTextArea(uis*4+90,"",nil,800/#options*uis,randomized-10,30,40,0x6A4A29,0xffffff,1,true)
  27.         ui.addTextArea(uis*4+89,"",nil,800/#options*uis+(800/#options-10)-20,randomized-10,30,40,0x6A4A29,0xffffff,1,true)
  28.         ui.addTextArea(uis*4+88,"",nil,800/#options*uis+30,randomized-20,(800/#options-10)-50,40,0x6A4A29,0xffffff,1,true)
  29.         ui.addTextArea(uis,"<p align=\"center\"><V>"..i.."</V><br><br><a href=\"event:mark\">click to vote</a></p>",nil,800/#options*uis+5,randomized,800/#options-10,400,0x4A2A09,0xffffff,1,true)
  30.        
  31.         tfm.exec.addPhysicObject(uis*3-3,(800/#options*uis+5)+(800/#options-10)/2,randomized,{type=0,height=10,width=800/#options-10,friction=1})
  32.         tfm.exec.addPhysicObject(uis*3-2,(800/#options*uis)+5,randomized+400,{type=0,height=800,width=10,friction=1})
  33.         tfm.exec.addPhysicObject(uis*3-1,(800/#options*uis)+(800/#options-10),randomized+400,{type=0,height=800,width=10,friction=1})
  34.         uis=uis+1
  35.     end
  36.     compose="not voted yet: "
  37.     for i in pairs(tfm.get.room.playerList) do
  38.         compose=compose..i.." "
  39.     end
  40.     ui.addTextArea(-2,"",nil,0,340,800,10,0x00ff00,0x00ff00,1,true)
  41.     ui.addTextArea(-1,compose,nil,0,350,800,100,0x361400,0x361400,1,true)
  42. end
  43.  
  44. function eventTextAreaCallback(id,j,c)
  45.     for v,i in pairs(votes) do
  46.         for b,n in pairs(i) do
  47.             for x,m in pairs(parent) do
  48.                 if x==id then
  49.                     if v==m then
  50.                         else
  51.                         return
  52.                     end
  53.                 end
  54.             end
  55.         end
  56.     end
  57.     local assign=""
  58.     for v,i in pairs(votes[parent[id]]) do
  59.         if j==i then
  60.             assign=v
  61.         end
  62.     end
  63.     if assign=="" then
  64.         votes[parent[id]][#votes[parent[id]]+1]=j
  65.         else
  66.         votes[parent[id]][assign]=nil
  67.     end
  68.     compose="<p align=\"center\"><V>"..parent[id].."</V><br><br><a href=\"event:mark\">click to vote</a><br>"
  69.     for _,i in pairs(votes[parent[id]]) do
  70.         compose=compose..i.."<br>"
  71.     end
  72.     ui.updateTextArea(id,compose)
  73.     compose={}
  74.     tabl={}
  75.     for i in pairs(tfm.get.room.playerList) do
  76.         compose[#compose+1]=i
  77.         tabl[#tabl+1]=i
  78.     end
  79.     for n,i in pairs(compose) do
  80.         for _,v in pairs(votes) do
  81.         for _,j in pairs(v) do
  82.             if j==i then
  83.                 tabl[n]=nil
  84.             end
  85.         end
  86.         end
  87.     end
  88.     compose="not voted yet: "
  89.     for _,i in pairs(tabl) do
  90.         compose=compose..i.." "
  91.     end
  92.     ui.addTextArea(-2,"",nil,0,340,800,10,0x00ff00,0x00ff00,1,true)
  93.     ui.updateTextArea(-1,compose)
  94. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement