Brenower

[TFM][Brenower] Cookie Clicker

Jan 22nd, 2014
1,064
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 9.04 KB | None | 0 0
  1. -- Cookie Clicker
  2. -- Créditos:Brenower
  3. -- Tables
  4. data={};
  5. mg={
  6.     ["cookies"]=0;
  7.     ["gc"]=0;
  8.     ["tgc"]=os.time();
  9.     ["ck"]=1;
  10.     ["clk"]=0;
  11.     ["gc"]=0;
  12.     ["cursor"]=0;
  13.     ["grandma"]=0;
  14.     ["farm"]=0;
  15.     ["factory"]=0;
  16.     ["mine"]=0;
  17.     ["shipment"]=0;
  18.     ["alchemylab"]=0;
  19.     ["portal"]=0;
  20.     ["timemachine"]=0;
  21.     ["antimatter"]=0;
  22.     ["s"]=100;
  23.     ["ts"]=os.time();
  24.     ["sm"]=0;
  25.     ["pc"]=0;
  26.     ["com"]="";
  27. };
  28. com={
  29.     ["c1"]=20;
  30.     ["c2"]=100;
  31.     ["c3"]=500;
  32.     ["c4"]=3000;
  33.     ["c5"]=10000;
  34.     ["c6"]=40000;
  35.     ["c7"]=200000;
  36.     ["c8"]=1667667;
  37.     ["c9"]=123456789;
  38.     ["c10"]=3999999999
  39. };
  40. den={
  41.     x1={30,30,30,40,40,40,50,50,60,40,50,50,60,70,70,80,80,90,90,90,80,80,70,70,70,60,60,50,40,50,50,60,60,70,80,70,60,50,70,60};
  42.     y1={310,320,330,330,310,300,300,290,290,340,340,350,350,350,340,340,330,330,320,310,310,300,300,290,310,310,300,310,320,320,330,340,330,330,320,320,320,320,310,330};
  43.     cor1={'0x000000','0x000000','0x000000','0x000000','0x000000','0x000000','0x000000','0x000000','0x000000','0x000000','0x000000','0x000000','0x000000','0x000000','0x000000','0x000000','0x000000','0x000000','0x000000','0x000000','0x000000','0x000000','0x000000','0x000000','0x65371A','0x65371A','0x65371A','0x65371A','0x65371A','0x65371A','0x65371A','0x65371A','0x65371A','0x65371A','0x65371A','0x65371A','0x65371A','0x47231C','0x47231C','0x47231C'};
  44.     ids1={1001,1002,1003,1004,1005,1006,1007,1008,1009,1010,1011,1012,1013,1014,1015,1016,1017,1018,1019,1020,1021,1022,1023,1024,1025,1026,1027,1028,1029,1030,1031,1032,1033,1034,1035,1036,1037,1038,1039,1040};
  45. };
  46. -- Outras tables
  47. ckids={};
  48. idd=0;
  49. gn=0;
  50. prm={};
  51. -- Functions
  52. function gText(id,p,x,y)
  53. if id == 1 then
  54. ui.addTextArea(1,"<font size='18' face='Comic Sans MS'>"..math.floor(mg.cookies).." Cookies",NIL,100,50,NIL,NIL,1,1,0.3)
  55. ui.addTextArea(17,"<TI><a href='event:help'><p align='center'>?",NIL,30,20,18,18,0x3C5064,0x27373F,1,true)
  56. end
  57. if id == 2 then
  58. mg.s=mg.s+1;
  59. table.insert(ckids,mg.s)
  60. ui.addTextArea(mg.s,"<font size='18' face='Comic Sans MS'>+"..mg.ck.."",NIL,x,y-5,NIL,0,0,0)
  61. mg.cookies=mg.cookies+mg.ck;
  62. gText(1)
  63. end
  64. if id == 3 then
  65. ui.addTextArea(2,"<font size='12' face='Comic Sans MS'>Cursor   |   <a href='event:cursor'>Comprar: <J>"..math.floor(com.c1).." Cookies</a><N><J><br /><N>Quantidade atual:<VP> "..math.floor(mg.cursor).."",NIL,424,38,200,NIL,0xB5B1A5,0x3D3A2B,0.3)
  66. end
  67. if id == 4 then
  68. ui.addTextArea(3,"<font size='12' face='Comic Sans MS'>Grandma   |   <a href='event:grandma'>Comprar: <J>"..math.floor(com.c2).." Cookies</a><N><J><br /><N>Quantidade atual:<VP> "..math.floor(mg.grandma).."",NIL,424,108,200,NIL,0xB5B1A5,0x3D3A2B,0.3)
  69. end
  70. if id == 5 then
  71. ui.addTextArea(4,"<font size='12' face='Comic Sans MS'>Fazenda   |   <a href='event:farm'>Comprar: <J>"..math.floor(com.c3).." Cookies</a><N><J><br /><N>Quantidade atual:<VP> "..math.floor(mg.farm).."",NIL,424,178,200,NIL,0xB5B1A5,0x3D3A2B,0.3)
  72. end
  73. if id == 6 then
  74. ui.addTextArea(5,"<font size='12' face='Comic Sans MS'>Fábrica   |   <a href='event:factory'>Comprar: <J>"..math.floor(com.c4).." Cookies</a><N><J><br /><N>Quantidade atual:<VP> "..math.floor(mg.factory).."",NIL,424,248,200,NIL,0xB5B1A5,0x3D3A2B,0.3)
  75. end
  76. if id == 7 then
  77. ui.addTextArea(6,"<font size='12' face='Comic Sans MS'>Mina  |   <a href='event:mine'>Comprar: <J>"..math.floor(com.c5).." Cookies</a><N><J><br /><N>Quantidade atual:<VP> "..math.floor(mg.mine).."",NIL,424,318,200,NIL,0xB5B1A5,0x3D3A2B,0.3)
  78. end
  79. if id == 8 then
  80. ui.addTextArea(7,"<font size='12' face='Comic Sans MS'>Nave  |   <a href='event:shipment'>Comprar: <J>"..math.floor(com.c6).." Cookies</a><N><J><br /><N>Quantidade atual:<VP> "..mg.shipment.."",NIL,850,38,200,NIL,0xB5B1A5,0x3D3A2B,0.3)
  81. end
  82. if id == 10 then
  83. ui.addTextArea(8,"<font size='12' face='Comic Sans MS'>Laboratório Alquimico  |   <a href='event:alchemylab'>Comprar: <J>"..math.floor(com.c7).." Cookies</a><N><J><br /><N>Quantidade atual:<VP> "..mg.alchemylab.."",NIL,850,178,200,NIL,0xB5B1A5,0x3D3A2B,0.3)
  84. end
  85. if id == 11 then
  86. ui.addTextArea(9,"<font size='12' face='Comic Sans MS'>Portal |   <a href='event:portal'>Comprar: <J>"..math.floor(com.c8).." Cookies</a><N><J><br /><N>Quantidade atual:<VP> "..mg.portal.."",NIL,850,248,200,NIL,0xB5B1A5,0x3D3A2B,0.3)
  87. end
  88. if id == 12 then
  89. ui.addTextArea(10,"<font size='12' face='Comic Sans MS'>Máquina do tempo |   <a href='event:timemachine'>Comprar: <J>"..math.floor(com.c9).." Cookies</a><N><J><br /><N>Quantidade atual:<VP> "..mg.timemachine.."",NIL,850,318,200,NIL,0xB5B1A5,0x3D3A2B,0.3)
  90. end
  91. if id == 13 then
  92. ui.addTextArea(11,"<font size='12' face='Comic Sans MS'>Convertor de anti-matéria |   <a href='event:antimatter'>Comprar: <J>"..math.floor(com.c10).." Cookies</a><N><J><br /><N>Quantidade atual:<VP> "..mg.antimatter.."",NIL,850,108,200,NIL,0xB5B1A5,0x3D3A2B,0.3)
  93. end
  94. if id == 14 then
  95. ui.addTextArea(12,"<V><TI>Ajuda - Cookie Clicker",p,75,100,650,100,0x27373F,0x27373F,1,true)
  96. ui.addTextArea(13,"<br /><br /><TI>Bem vindo ao cookie clicker, seu objetivo é dominar o mundo de cookies! :)<br />Aperte no cookie e gere mais cookies para o seu grande imperio de biscoitos ou compre uma fábrica para gerar cookies automaticamente!!!<br />Compre upgrades para fazer melhorias no jogo e ganhar ainda mais cookies.<br />Jogue com seus amigos ou sozinho.<br />Fale <V>!salvar<N> para poder guardar o estado atual do seu grande imperio de biscoitos.",p,75,130,650,250,0x324650,0x27373F,1,true)
  97. ui.addTextArea(14,"<p align='center'><font color='#27373F'><B><a href='event:close'>X</a>",p,705,100,15,16,0x009D9D,0x27373F,1,true)
  98. ui.addTextArea(15,"<p align='center'><VP>Ajuda",p,80,135,150,15,0x3C5064,0x27373F,1,true)
  99. ui.addTextArea(16,"<p align='center'><a href='event:stats'>Estatísticas",p,260,135,150,15,0x3C5064,0x27373F,1,true)
  100. end
  101. if id == 15 then
  102. ui.addTextArea(12,"<V><TI>Estatísticas - Cookie Clicker",p,75,100,650,100,0x27373F,0x27373F,1,true)
  103. ui.addTextArea(13,"<br /><br /><TI>Quantidade de vezes clicada no cookie : <V>"..mg.clk.."<br /><N>Tempo em segundos que você está jogando : <V>"..mg.sm.."<br /><N>Cookies por segundo : <V>"..math.floor(mg.gc).."",p,75,130,650,250,0x324650,0x27373F,1,true)
  104. ui.addTextArea(14,"<p align='center'><font color='#27373F'><B><a href='event:close'>X</a>",p,705,100,15,16,0x009D9D,0x27373F,1,true)
  105. ui.addTextArea(15,"<p align='center'><a href='event:help'>Ajuda",p,80,135,150,15,0x3C5064,0x27373F,1,true)
  106. ui.addTextArea(16,"<p align='center'><VP>Estatísticas",p,260,135,150,15,0x3C5064,0x27373F,1,true)
  107. end
  108. if id == 16 then
  109. ui.addTextArea(18,"<V><TI>Ultimas compras :<font size='12'><N>"..mg.com.."",NIL,1158,50,400,NIL,0.0,0)
  110. end
  111. end
  112. function f5table(prd,pr,p)
  113. x="<br /><J>["..p.."] <N>Comprou <VP>"..prd.."<N> por <CH>"..math.floor(pr).." cookies!";
  114. if #prm <= 19 then
  115. table.insert(prm,x)
  116. mg.com=mg.com..""..x.."";
  117. else
  118. table.remove(prm,1)
  119. table.insert(prm,x)
  120. mg.com="";
  121. for i,v in pairs(prm) do
  122. mg.com=mg.com..""..v.."";
  123. end
  124. end
  125. gText(16)
  126. end
  127. function buy(id,prd,c,player)
  128. if mg.cookies >= com[c] then
  129. f5table(prd,com[c],player)
  130. mg.cookies=mg.cookies-com[c];
  131. mg[prd]=mg[prd]+1;
  132. com[c]=com[c]+com[c];
  133. gn=com[c];
  134. mg.gc=mg.gc+gn/500;
  135. end
  136. for i = 3,13 do
  137. gText(i)
  138. end
  139. gText(1)
  140. tfm.exec.setUIMapName("<N>Cookies por segundo : <J>"..math.floor(mg.gc).."")
  141. end
  142. function giveData(p)
  143. if not data[p] then
  144. nD={
  145.     ["time"]=os.time();
  146. };
  147. data[p] = nD;
  148. end
  149. system.bindMouse(p,true)
  150. for i = 3,14 do
  151. gText(i,p,0,0)
  152. end
  153. gText(1)
  154. end
  155. -- Inicio do script
  156. for i in pairs(tfm.get.room.playerList) do
  157. giveData(i)
  158. end
  159. tfm.exec.disableAutoNewGame(true)
  160. tfm.exec.disableAutoShaman(true)
  161. tfm.exec.disableAfkDeath(true)
  162. tfm.exec.newGame(4721074)
  163. system.bindMouse("Brenower",true)
  164. function eventMouse(player,x,y)
  165. if x >= 45 and x <= 249 and y >= 98 and y <= 294 then
  166. if data[player].time < os.time()-150 then
  167. gText(2,player,x,y)
  168. data[player].time=os.time();
  169. mg.clk=mg.clk+1;
  170. tfm.exec.displayParticle(29,x,y,-1,-2,0,0,NIL)
  171. tfm.exec.displayParticle(29,x,y,-3,2,0,0,NIL)
  172. tfm.exec.displayParticle(29,x,y,1,-2,0,0,NIL)
  173. tfm.exec.displayParticle(29,x,y,3,2,0,0,NIL)
  174. end
  175. end
  176. if x >= 30 and x <= 70 and y >= 290 and y <= 350 and mg.gc == 1 then
  177. mg.cookies=mg.cookies*2;
  178. mg.gc=0;
  179. for i = #den.x1,1,-1 do
  180. ui.removeTextArea(den.ids1[i],nil)
  181. end
  182. end
  183. end
  184. -- Loop
  185. function eventLoop()
  186. mg.sm=mg.sm+0.5;
  187. if #ckids >= 1 then
  188. ui.removeTextArea(ckids[1],NIL)
  189. table.remove(ckids,1)
  190. end
  191. if mg.ts < os.time()-1500 then
  192. mg.cookies=mg.cookies+mg.gc;
  193. gText(1)
  194. end
  195. if mg.tgc < os.time()-90000 and mg.gc == 0 then
  196. mg.gc=1;
  197. mg.tgc=os.time();
  198. for i = #den.x1,1,-1 do
  199. ui.addTextArea(den.ids1[i],"<font color='#"..string.sub(den.cor1[i],3).."'><font size='13'>■",nil,den.x1[i],den.y1[i],nil,nil,0,0,0)
  200. end
  201. end
  202. end
  203. -- Novo jogador entra na sala
  204. function eventNewPlayer(p)
  205. giveData(p)
  206. tfm.exec.respawnPlayer(p)
  207. end
  208. -- Callbacks
  209. function eventTextAreaCallback(id,player,link)
  210. if link == [[close]] then
  211. for i = 12,16 do
  212. ui.removeTextArea(i,player)
  213. end
  214. end
  215. if link == [[help]] then
  216. gText(14,player)
  217. end
  218. if link == [[stats]] then
  219. gText(15,player)
  220. end
  221. if  link ~= [[close]] and link ~= [[help]] and link ~= [[stats]] then
  222. idd=id;
  223. idd=idd-1;
  224. buy(idd,""..link.."","c"..idd.."",player)
  225. end
  226. end
  227. -- Comandos
Advertisement
Add Comment
Please, Sign In to add comment