Advertisement
Guest User

Untitled

a guest
Sep 21st, 2019
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.92 KB | None | 0 0
  1. -- Four in a row
  2. -- Escrito por Ninguem -- Data: 03/10/2015
  3.  
  4. adm = "Ninguem"
  5. tempoDaJogada = 20000
  6. cor = {0x2285b6, 0xff4747}
  7.  
  8. code = [[<C><P Ca="" /><Z><S><S P="0,0,0.3,0.2,0,0,0,0" L="3000" o="171226" X="400" c="3" Y="385" T="12" H="30" /><S P="0,0,0.3,0,0,0,0,0" L="360" o="28203e" X="400" c="4" Y="300" T="12" H="10" /><S H="10" L="360" o="28203e" X="400" c="4" Y="250" T="12" P="0,0,0.3,0.2,0,0,0,0" /><S H="10" L="360" o="28203e" X="400" c="4" Y="150" T="12" P="0,0,0.3,0.2,0,0,0,0" /><S P="0,0,0.3,0.2,0,0,0,0" L="360" o="28203e" X="400" c="4" Y="100" T="12" H="10" /><S P="0,0,0.3,0.2,0,0,0,0" L="360" o="28203e" X="400" c="4" Y="200" T="12" H="10" /><S H="10" L="360" o="28203e" X="400" c="4" Y="50" T="12" P="0,0,0.3,0.2,0,0,0,0" /><S P="0,0,0,0.2,0,0,0,0" L="10" o="2d2642" X="225" c="2" Y="200" T="12" H="310" /><S H="310" L="10" o="2d2642" X="275" c="2" Y="200" T="12" P="0,0,0,0.2,0,0,0,0" /><S P="0,0,0,0.2,0,0,0,0" L="10" o="2d2642" X="325" c="2" Y="200" T="12" H="310" /><S H="310" L="10" o="2d2642" X="375" c="2" Y="200" T="12" P="0,0,0,0.2,0,0,0,0" /><S P="0,0,0,0.2,0,0,0,0" L="10" o="2d2642" X="425" c="2" Y="200" T="12" H="310" /><S H="310" L="10" o="2d2642" X="475" c="2" Y="200" T="12" P="0,0,0,0.2,0,0,0,0" /><S P="0,0,0,0.2,0,0,0,0" L="10" o="2d2642" X="525" c="2" Y="200" T="12" H="310" /><S H="310" L="10" o="2d2642" X="575" c="2" Y="200" T="12" P="0,0,0,0.2,0,0,0,0" /><S P="0,0,0.3,0.2,0,0,0,0" L="3000" o="171226" X="400" N="" Y="23" T="12" H="10" /><S P="0,0,0.3,0.2,0,0,0,0" L="400" o="2285b6" X="200" N="" Y="23" T="12" H="10" /><S L="400" o="ff4747" X="600" H="10" N="" Y="23" T="12" P="0,0,0.3,0.2,0,0,0,0" /><S H="10" L="360" o="2d2642" X="400" c="4" Y="350" T="12" P="0,0,0.3,0,0,0,0,0" /><S P="0,0,0.3,0.2,0,0,0,0" L="100" o="171226" X="720" Y="300" T="12" H="200" /><S L="100" o="171226" X="80" H="200" Y="300" T="12" P="0,0,0.3,0.2,0,0,0,0" /><S X="126" L="160" H="10" lua="3333" Y="290" T="%d" P="0,0,%f,%f,90,0,0,0" /><S H="10" L="160" X="674" lua="4444" Y="290" T="%d" P="0,0,%f,%f,-90,0,0,0" /><S H="30" L="60" X="80" c="3" Y="192" T="14" P="0,0,0.3,0.2,0,0,0,0" /><S P="0,0,0.3,0.2,0,0,0,0" L="60" H="30" c="3" Y="192" T="14" X="720" /><S L="20" o="171226" H="10" X="122" Y="205" T="12" P="0,0,0.3,0.2,0,0,0,0" /><S P="0,0,0.3,0.2,0,0,0,0" L="20" o="171226" X="678" Y="205" T="12" H="10" /></S><D><P C="2a2244" Y="0" T="34" X="0" P="0,0" /><P C="2285b6,bde8f3,faf1b3" Y="332" T="14" P="0,0" X="-87" /><P C="2285b6" Y="200" T="19" X="80" P="0,0" /><P C="ff4747,bde8f3,faf1b3" Y="324" T="14" X="887" P="0,0" /><P C="ff4747" Y="200" T="19" P="0,0" X="720" /><P C="555d77" Y="389" T="131" X="400" P="1,0" /><P C="ff4747,bde8f3,faf1b3" Y="350" T="14" P="1,0" X="895" /><P C="ff4747,bde8f3,faf1b3" Y="180" T="14" X="892" P="1,0" /><P C="2285b6,bde8f3,faf1b3" Y="350" T="14" X="-95" P="1,0" /><P C="2285b6,bde8f3,faf1b3" Y="180" T="14" X="-95" P="1,0" /><P C="2285b6,bde8f3,faf1b3" Y="164" T="14" P="0,0" X="-88" /><P C="ff4747,bde8f3,faf1b3" Y="157" T="14" P="0,0" X="883" /><DS Y="343" X="400" /><P C="fdfdfd" Y="-30" T="90" X="400" P="0,0" /></D><O /></Z></C>]]
  9. -- code = "@6281248" -- vers?o com tela e menos wj
  10.  
  11. piso = {
  12. {id=0, f=0.3, r=0.2},
  13. {id=2, f=0.5, r=2},
  14. {id=3, f=0.5, r=999999},
  15. {id=4, f=20, r=0.2},
  16. {id=5, f=0.3, r=0.2},
  17. {id=6, f=0.3, r=0.2},
  18. {id=7, f=0.1, r=0.2},
  19. {id=10, f=0.3, r=0},
  20. {id=11, f=0.05, r=0.1}
  21. }
  22.  
  23. modo = "inicio"
  24. vez = 1
  25. jogador = {}
  26. tabela = {}
  27. intervalo = os.time()+2000
  28. tempoFim = os.time()
  29. tempoMapa = os.time() + 3000
  30. tempoJogada = os.time() + 15000
  31. obj = 0
  32.  
  33. tabela = {}
  34. for i=1, 7 do
  35. tabela[i] = {}
  36. for j=1, 6 do
  37. tabela[i][j] = 0
  38. end
  39. end
  40.  
  41. function novaTabela()
  42. for i=1, 7 do
  43. for j=1, 6 do
  44. tabela[i][j] = 0
  45. end
  46. end
  47. end
  48.  
  49. function exibeNome(i)
  50. ui.addTextArea(i, "<p align='center'><j>"..jogador[i], nil, (i==1) and 20 or 660, 220, 120, 30, 0, 0, 0, true)
  51. end
  52.  
  53. function eventNewPlayer(p)
  54. tfm.exec.bindKeyboard(p, 32, true, true)
  55. end
  56.  
  57. function eventNewGame()
  58. modo = "inicio"
  59. novaTabela()
  60. tempoMapa = os.time() + 3000
  61. jogador[1] = nil
  62. jogador[2] = nil
  63. ui.addTextArea(1, "<p align='center'><vp>[espaço]", nil, 20, 220, 120, 30, 0, 0, 0, true)
  64. ui.addTextArea(2, "<p align='center'><vp>[espaço]", nil, 660, 220, 120, 30, 0, 0, 0, true)
  65. ui.removeTextArea(3)
  66. ui.removeTextArea(4)
  67. tfm.exec.addPhysicObject(8000, 0, 0, {type=14, miceCollision=false})
  68. tfm.exec.setUIMapName("Four in a row")
  69. jogador = {}
  70. for i, v in pairs(tfm.get.room.playerList) do
  71. system.bindMouse(i, false)
  72. tfm.exec.setNameColor(i, 0xC2C2CA)
  73. eventNewPlayer(i)
  74. end
  75. end
  76.  
  77. function eventKeyboard(p, t, d, x, y)
  78. if modo == "inicio" and os.time() > tempoMapa then
  79. if x > 50 and x < 110 and not jogador[1] then
  80. jogador[1] = p
  81. system.bindMouse(p, true)
  82. exibeNome(1)
  83. tfm.exec.setNameColor(p, cor[1])
  84. elseif x > 690 and x < 750 and not jogador[2] then
  85. jogador[2] = p
  86. system.bindMouse(p, true)
  87. exibeNome(2)
  88. tfm.exec.setNameColor(p, cor[2])
  89. end
  90. if jogador[1] and jogador[2] then
  91. modo = "partida"
  92. tempoJogada = tempoDaJogada + os.time()
  93. vez = math.random(1,2)
  94. tfm.exec.removeObject(obj)
  95. obj = tfm.exec.addShamanObject(57, vez == 1 and 80 or 720, 50, 0, 0, 0, true)
  96. end
  97. end
  98. end
  99.  
  100. function linhaVertical(p)
  101. local p1, p2 = {}, {}
  102. for i=1, 7 do
  103. for j=1, 3 do
  104. if tabela[i][j] == p and tabela[i][j+1] == p and tabela[i][j+2] == p and tabela[i][j+3] == p then
  105. p1 = {i, j}
  106. p2 = {i, j+3}
  107. return p1, p2
  108. end
  109. end
  110. end
  111. end
  112.  
  113. function linhaHorizontal(p)
  114. local p1, p2 = {}, {}
  115. for i=1, 4 do
  116. for j=1, 6 do
  117. if tabela[i][j] == vez and tabela[i+1][j] == p and tabela[i+2][j] == p and tabela[i+3][j] == p then
  118. p1 = {i, j}
  119. p2 = {i+3, j}
  120. return p1, p2
  121. end
  122. end
  123. end
  124. end
  125.  
  126. function linhaDiagonal1(p)
  127. local p1, p2 = {}, {}
  128. for i=1, 4 do
  129. for j=1, 3 do
  130. if tabela[i][j] == vez and tabela[i+1][j+1] == p and tabela[i+2][j+2] == p and tabela[i+3][j+3] == p then
  131. p1 = {i, j}
  132. p2 = {i+3, j+3}
  133. return p1, p2
  134. end
  135. end
  136. end
  137. end
  138.  
  139. function linhaDiagonal2(p)
  140. local p1, p2 = {}, {}
  141. for i=4, 7 do
  142. for j=1, 3 do
  143. if tabela[i][j] == p and tabela[i-1][j+1] == p and tabela[i-2][j+2] == p and tabela[i-3][j+3] == p then
  144. p1 = {i, j}
  145. p2 = {i-3, j+3}
  146. return p1, p2
  147. end
  148. end
  149. end
  150. end
  151.  
  152. function verificaVitoria(p)
  153. local p1, p2 = false, false
  154. if linhaVertical(p) then
  155. p1, p2 = linhaVertical(p)
  156. elseif linhaHorizontal(p) then
  157. p1, p2 = linhaHorizontal(p)
  158. elseif linhaDiagonal1(p) then
  159. p1, p2 = linhaDiagonal1(p)
  160. elseif linhaDiagonal2(p) then
  161. p1, p2 = linhaDiagonal2(p)
  162. end
  163. if p1 and p2 then
  164. modo = "fim"
  165. tempoFim = os.time() + 10000
  166. local x1 = 200+p1[1]*50
  167. local y1 = 375-p1[2]*50
  168. local x2 = 200+p2[1]*50
  169. local y2 = 375-p2[2]*50
  170. tfm.exec.addJoint(8000, 8000, 8000, {point1=x1..","..y1, point2=x2..","..y2, color=cor[p], line=4, foreground=true})
  171. tfm.exec.setPlayerScore(jogador[p], 1, true)
  172. ui.addTextArea(3, "", nil, 0, 0, 800, 400, 1, 1, 0.3, true)
  173. ui.addTextArea(4, string.format("<p align='center'><font color='#ffffff' size='60px'>%s venceu o jogo!", jogador[p]), nil, 0, 120, 800, 400, 0, 0, 0, true)
  174. end
  175. intervalo = os.time()+2000
  176. end
  177.  
  178. function semJogada()
  179. for i=1, 7 do
  180. if tabela[i][6] == 0 then
  181. return false
  182. end
  183. end
  184. return true
  185. end
  186.  
  187. function verificaEmpate()
  188. if modo == "partida" then
  189. if semJogada() then
  190. ui.addTextArea(3, "", nil, 0, 0, 800, 400, 1, 1, 0.3, true)
  191. ui.addTextArea(4, string.format("<p align='center'><font color='#ffffff' size='60px'>Empate"), nil, 0, 120, 800, 400, 0, 0, 0, true)
  192. modo = "fim"
  193. tempoFim = os.time() + 10000
  194. end
  195. end
  196. end
  197.  
  198. function passaVez()
  199. vez = vez == 1 and 2 or 1
  200. tfm.exec.removeObject(obj)
  201. obj = tfm.exec.addShamanObject(57, vez == 1 and 80 or 720, 50, 0, 0, 0, true)
  202. tempoJogada = os.time() + tempoDaJogada
  203. end
  204.  
  205. function autoPlay()
  206. local pool = {}
  207. for i=1, 7 do
  208. if tabela[i][6] == 0 then
  209. table.insert(pool, i)
  210. end
  211. end
  212. eventMouse(jogador[vez], 200+pool[math.random(#pool)]*50, 0)
  213. end
  214.  
  215. function eventChatCommand(p, cmd)
  216. if p == adm and cmd == "new" then
  217. modo = "inicio"
  218. local e = math.random(#piso)
  219. tfm.exec.newGame(string.format(code, piso[e].id, piso[e].f, piso[e].r, piso[e].id, piso[e].f, piso[e].r))
  220. end
  221. end
  222.  
  223. function eventMouse(p, x, y)
  224. if modo == "partida" then
  225. if jogador[vez] == p and os.time() > intervalo then
  226. local xx = math.ceil((x - 225)/50)
  227. if tabela[xx] then
  228. if tabela[xx][1] == 0 then
  229. tabela[xx][1] = vez
  230. tfm.exec.addPhysicObject(xx*6+1+2000, 200 + (xx * 50), 350, {type=14, miceCollision=false})
  231. tfm.exec.addPhysicObject(xx*6+1+1000, 200 + (xx * 50), 50, {type=13, width=19, mass=999999, color=cor[vez], dynamic=true, miceCollision=false, foreground=true})
  232. verificaVitoria(vez)
  233. verificaEmpate()
  234. passaVez()
  235. elseif tabela[xx][2] == 0 then
  236. tabela[xx][2] = vez
  237. tfm.exec.addPhysicObject(xx*6+2+2000, 200 + (xx * 50), 300, {type=14, miceCollision=false})
  238. tfm.exec.addPhysicObject(xx*6+2+1000, 200 + (xx * 50), 50, {type=13, width=19, mass=999999, color=cor[vez], dynamic=true, miceCollision=false, foreground=true})
  239. verificaVitoria(vez)
  240. verificaEmpate()
  241. passaVez()
  242. elseif tabela[xx][3] == 0 then
  243. tabela[xx][3] = vez
  244. tfm.exec.addPhysicObject(xx*6+3+2000, 200 + (xx * 50), 250, {type=14, miceCollision=false})
  245. tfm.exec.addPhysicObject(xx*6+3+1000, 200 + (xx * 50), 50, {type=13, width=19, mass=999999, color=cor[vez], dynamic=true, miceCollision=false, foreground=true})
  246. verificaVitoria(vez)
  247. verificaEmpate()
  248. passaVez()
  249. elseif tabela[xx][4] == 0 then
  250. tabela[xx][4] = vez
  251. tfm.exec.addPhysicObject(xx*6+4+2000, 200 + (xx * 50), 200, {type=14, miceCollision=false})
  252. tfm.exec.addPhysicObject(xx*6+4+1000, 200 + (xx * 50), 50, {type=13, width=19, mass=999999, color=cor[vez], dynamic=true, miceCollision=false, foreground=true})
  253. verificaVitoria(vez)
  254. verificaEmpate()
  255. passaVez()
  256. elseif tabela[xx][5] == 0 then
  257. tabela[xx][5] = vez
  258. tfm.exec.addPhysicObject(xx*6+5+2000, 200 + (xx * 50), 150, {type=14, miceCollision=false})
  259. tfm.exec.addPhysicObject(xx*6+5+1000, 200 + (xx * 50), 50, {type=13, width=19, mass=999999, color=cor[vez], dynamic=true, miceCollision=false, foreground=true})
  260. verificaVitoria(vez)
  261. verificaEmpate()
  262. passaVez()
  263. elseif tabela[xx][6] == 0 then
  264. tabela[xx][6] = vez
  265. tfm.exec.addPhysicObject(xx*6+6+2000, 200 + (xx * 50), 100, {type=14, miceCollision=false})
  266. tfm.exec.addPhysicObject(xx*6+6+1000, 200 + (xx * 50), 50, {type=13, width=19, mass=999999, color=cor[vez], dynamic=true, miceCollision=false, foreground=true})
  267. verificaVitoria(vez)
  268. verificaEmpate()
  269. passaVez()
  270. end
  271. end
  272. end
  273. end
  274. end
  275.  
  276. function eventPlayerLeft(p)
  277. if jogador[1] == p or jogador[2] == p then
  278. modo = "fim"
  279. tempoFim = os.time() + 10000
  280. end
  281. end
  282.  
  283. function eventLoop(current, remaining)
  284. if modo == "fim" and os.time() > tempoFim then
  285. eventChatCommand(adm, "new")
  286. elseif modo == "partida" then
  287. if os.time() > tempoJogada then
  288. autoPlay()
  289. end
  290. end
  291. end
  292. for i, v in pairs(tfm.get.room.playerList) do
  293. tfm.exec.setPlayerScore(i, 0, false)
  294. end
  295. tfm.exec.disableAfkDeath(true)
  296. tfm.exec.disableAutoShaman(true)
  297. tfm.exec.disableAutoNewGame(true)
  298. e = math.random(#piso)
  299. tfm.exec.newGame(string.format(code, piso[e].id, piso[e].f, piso[e].r, piso[e].id, piso[e].f, piso[e].r))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement