Advertisement
Dudugz-Contistente

Untitled

Feb 27th, 2017
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.31 KB | None | 0 0
  1. tfm.exec.disableAutoNewGame()
  2. tfm.exec.disableAutoShaman()
  3. tfm.exec.disableAutoTimeLeft()
  4. tfm.exec.disableAutoScore()
  5.  
  6. start=os.time()
  7. _Vento = math.random(1,4)
  8. vento = os.time();
  9.  
  10. at=1
  11. vivos=0
  12.  
  13. languages = {
  14. {
  15. welcome = "<VP>●</VP> <J>Olá %s bem-vindo(a) ao <I>Sky</I>.</J></B><BR><BL>Minigame em desenvolvimento versão alpha 0.12<BR>Minigame criado por: Contistente<BR>Ajudantes e Participantes:<BR>Lynezx e Fofinhoppp<BR>Dúvidas ou quer ver os comandos, digite !help</BL>",
  16. help = "<p align='center'><B><J><font size='15'>Como Jogar</font></J></B></p><BR><font size='12'><CE>O objetivo do jogo é chegar ao topo do mapa, todos os mapas do minigame são <B>Gerados aleatóriamente</B> pelo minigame, para não dificultar muito todos os jogadores tem 3 vidas e double jump apertando a tecla <B>Espaço</B>.</CE></font><BR><p align='center'><B><J><font size='15'>Comandos do Sky</font></J></B></p><br><BL><font size='12'><B>!lang [BR/E] - Define a linguagem do jogo apenas para você(Desativado).<BR>!help - Abre a janela de ajuda e comandos.</font>"
  17. }
  18. }
  19.  
  20. textarea=ui.addTextArea
  21. function ui.addTextArea(id,text,targetPlayer,x,y,width,height,backgroundColor,borderColor,backgroundAlpha,emboss,active)
  22. --if not backgroundColor then backgroundColor=0x324650 end
  23. --if not borderColor then borderColor=0x000001 end
  24. if active then
  25. textarea(6969+id,"",targetPlayer,x,y+1,width,height,0x000001,0x000001,backgroundAlpha,emboss)
  26. textarea(7979+id,"",targetPlayer,x,y-1,width,height,0x6A8FA2,0x6A8FA2,backgroundAlpha,emboss)
  27. end
  28. textarea(id,text,targetPlayer,x,y,width,height,backgroundColor,borderColor,backgroundAlpha,emboss)
  29. end
  30.  
  31. addPopup=ui.addPopup
  32. function ui.addPopup(id,tipo,texto,nome,x,y,largura,height,fixo)
  33. if tipo ~= 4 then
  34. addPopup(id,tipo,texto,nome,x,y,largura,height)
  35. else
  36. ui.addTextArea(id,texto,nome,x,y,largura,height,0x324650,0x324650,nil,true,true)
  37. ui.addTextArea(id+1,"<p align='center'><font size='12'><a href='event:close_popup'>Fechar</a></font></p>",nome,x+5,y+height-22,largura-10,18,0x3c5063,0x3c5063,nil,true,true)
  38. end
  39. end
  40.  
  41. function traduction(name)
  42. langs = {}
  43. langs["br"]=1
  44. langs["en"]=1
  45.  
  46. return languages[langs[data[name].lang]]
  47. end
  48.  
  49. function sendNewMap()
  50. takeMul = function(x)
  51. return x-(x%5)
  52. end
  53.  
  54.  
  55. math.randomseed = 9
  56.  
  57. xml = {}
  58.  
  59. flipmode = math.random(0,2)
  60.  
  61. if flipmode == 1 then
  62. tfm.exec.setAutoMapFlipMode(false)
  63. else
  64. tfm.exec.setAutoMapFlipMode()
  65. end
  66.  
  67. xml.standard = "<C><P Ca='' H='3000' F=\""..(math.random(0,8)%6).."\" /><Z><S>%s</S><D>%s</D><O /></Z></C>"
  68.  
  69. xml.grounds,xml.decorations = {},{}
  70.  
  71. xml.S,xml.SET,xml.D = '<S c="1" L="%d" H="%d" X="%d" Y="%d" T="%d" P="0,0,%f,%f,%d,0,0,0" o="%d" />','<%s X="%d" Y="%d" />','<P P="0,0" X="%d" Y="%d" T="%d" />'
  72.  
  73. grounds = {{0,1,4},{10,1},{12,13},{1,2},{4,1},{1,10},{10,9,2}}
  74. groundProperties = {{.3,.2},{0,.2},{0,1.2},{0,20},{20,.2},{.3,.2},{.3,.2},{.1,.2},{.3,.2},{0,0},{.3,0},{.05,.1},{.3,.2},{.3,.2},{.3,.2},{0,0}}
  75. decorations = {{0,4,5},{},{},{},{1,42,51},{1,2,4,12,18,20,32,42,46},{0,1,2,3,4,5,11,42},{7,8,9,10},{},{},{42,103,118},{51,106},{},{},{},{}}
  76.  
  77. currentX,currentY = 0,0
  78. mapGrounds = grounds[math.random(#grounds)]
  79. for i = 1,245 do
  80. local ground = mapGrounds[i==1 and i or math.random(#mapGrounds)]
  81. local L = takeMul(ground~=13 and math.random(40,120) or math.random(20,40))
  82. local H = takeMul(math.random(20,35))
  83. if ground == 9 and math.random(10) < 6 then
  84. L,H = H,L
  85. end
  86. local X,Y
  87. repeat
  88. X = takeMul(math.random(-50,860) - L - (currentX/8))
  89. Y = takeMul(math.random(100,2500) + (currentY/4))
  90. until X > 0 and X < 800 and Y > 0 and Y < 3001
  91. currentX,currentY = X - X^.5,Y + Y^.5
  92. table.insert(xml.grounds,xml.S:format(L,H,X,Y,ground,groundProperties[ground+1][1],groundProperties[ground+1][2],i==1 and math.random(-10,10) or math.random(0,360),math.random(0,0xFFFFFF)))
  93. if math.random(22) < 3 then
  94. local dec = decorations[ground+1]
  95. table.insert(xml.decorations,xml.D:format(X - math.random(-((L/4)+1),((L/4)+1)),Y - (H/2),#dec>0 and dec[math.random(#dec)] or -1))
  96. end
  97. if i == 1 then
  98. for k,v in next,{"DS","T"} do
  99. table.insert(xml.decorations,xml.SET:format(v,400,2900 - (H/2)))
  100. end
  101. end
  102. end
  103.  
  104. tfm.exec.newGame(xml.standard:format(table.concat(xml.grounds),table.concat(xml.decorations)))
  105. tfm.exec.addPhysicObject(0, 400, 2930, {type=math.random(0,14),width=100,miceCollision=true,friction=0.3,restitution=0.2})
  106. end
  107.  
  108. data={}
  109.  
  110. function eventTextAreaCallback(id,name,link)
  111. if link == "close_popup" then
  112. ui.removeTextArea(id,name)
  113. ui.removeTextArea(id-1,name)
  114. ui.removeTextArea(6969+id,name)
  115. ui.removeTextArea(6969+id-1,name)
  116. ui.removeTextArea(7979+id,name)
  117. ui.removeTextArea(7979+id-1,name)
  118. end
  119. end
  120.  
  121. function eventChatMessage(name,cmd)
  122. if cmd == "!help" or cmd == "!ajuda" then
  123. lang = traduction(name)
  124. ui.addPopup(100,4,string.format(lang.help,name),name,200,100,400,200,true)
  125. end
  126. end
  127.  
  128. function eventNewPlayer(name)
  129. if not data[name] then
  130. data[name]={
  131. fly=os.time(),
  132. maxLife=3,
  133. life=3,
  134. lang=""
  135. }
  136. end
  137.  
  138. tfm.exec.setPlayerScore(name,0,false)
  139.  
  140. data[name].lang = tfm.get.room.playerList[name].community
  141.  
  142. if traduction(name) == nil then
  143. data[name].lang = "en"
  144. end
  145.  
  146. lang = traduction(name)
  147. ui.addPopup(100,4,string.format(lang.welcome,name),name,200,100,400,120,true)
  148. tfm.exec.chatMessage(string.format(lang.welcome,name),name)
  149.  
  150. if tfm.get.room.playerList[name].isDead then
  151. data[name].life = 0
  152. end
  153.  
  154. system.bindKeyboard(name,32,true)
  155. end
  156.  
  157. function eventPlayerDied(name)
  158. if start < os.time()-1000 then
  159. if data[name].life > 0 then
  160. data[name].life=data[name].life-1;
  161.  
  162. if data[name].life > 0 then
  163. tfm.exec.respawnPlayer(name)
  164. end
  165. end
  166.  
  167. if data[name].life == 0 then
  168. tfm.exec.chatMessage("Você perdeu todos seus corações e não pode mais reviver neste mapa.",name)
  169. vivos=vivos-1;
  170. end
  171. else
  172. tfm.exec.respawnPlayer(name)
  173. end
  174. end
  175.  
  176. function eventLoop(t,r)
  177.  
  178. if vivos <= 3 and at == 1 then
  179. at = 0
  180. tfm.exec.setGameTime(30,true)
  181. end
  182.  
  183. str=""
  184.  
  185. if vento < os.time()-6000 then
  186. _Vento = math.random(1,4)
  187. vento = os.time();
  188. end
  189.  
  190. for i=1,_Vento do
  191. if i <= 1 then
  192. str=str.."<font color='#00BFFF'>▲</font>"
  193. elseif i <= 2 then
  194. str=str.."<font color='#FFCC00'>▲</font>"
  195. elseif i <= 3 then
  196. str=str.."<font color='#00FF00'>▲</font>"
  197. elseif i <= 4 then
  198. str=str.."<font color='#FF0000'>▲</font>"
  199. end
  200. end
  201.  
  202. if _Vento == 3 then
  203. str = str.."<font color='#2C2C2C'>▲</font>"
  204. end
  205.  
  206. if _Vento == 2 then
  207. str = str.."<font color='#2C2C2C'>▲▲</font>"
  208. end
  209.  
  210. if _Vento == 1 then
  211. str = str.."<font color='#2C2C2C'>▲▲▲</font>"
  212. end
  213.  
  214. if r < 1000 or vivos == 0 then
  215. sendNewMap()
  216. end
  217.  
  218. for i,v in pairs(tfm.get.room.playerList) do
  219. if not v.isDead and v.y <= 300 then
  220. tfm.exec.giveCheese(i)
  221. tfm.exec.playerVictory(i)
  222. end
  223.  
  224. ui.addTextArea(0,"",i,4.9,360,45,50,0x1C1C1C,0x1C1C1C,nil,true,true,true)
  225. ui.addTextArea(1,hearts(i),i,5,350,50,40,0,0,0,true)
  226. ui.addTextArea(2,"<B><font size='10'>"..str.."</font><BR><VP><B>"..(3000-v.y).."m",i,5,365,50,40,0,0,0,true)
  227. end
  228. end
  229.  
  230. function hearts(name)
  231. s=""
  232.  
  233. if data[name].life == data[name].maxLife then
  234. for i=1,data[name].life do
  235. s=s.."<font color='#FF0000' size='15'><B>♥</font>"
  236. end
  237. end
  238.  
  239. if data[name].life < data[name].maxLife then
  240. for i=1,data[name].life do
  241. s=s.."<font color='#FF0000' size='15'><B>♥</font>"
  242. end
  243.  
  244. m = data[name].maxLife-data[name].life
  245.  
  246. for i=1,m do
  247. s=s.."<font color='#8B0000' size='15'><B>♥</font>"
  248. end
  249. end
  250.  
  251. return s
  252. end
  253.  
  254. function eventNewGame()
  255. vivos=0
  256. tfm.exec.setGameTime(220,true)
  257.  
  258. start=os.time()
  259.  
  260. for i in pairs(tfm.get.room.playerList) do
  261. vivos=vivos+1;
  262. data[i].life=3
  263. tfm.exec.respawnPlayer(i)
  264. end
  265.  
  266. w=0
  267. at=1
  268. end
  269.  
  270. function eventPlayerWon(name)
  271. w=w+1;
  272.  
  273. if w <= 3 then
  274. if w == 3 then
  275. n=1
  276. elseif w == 2 then
  277. n=2
  278. elseif w == 1 then
  279. n=3
  280. end
  281.  
  282. tfm.exec.setPlayerScore(name,n*3,true)
  283. end
  284. end
  285.  
  286. function eventKeyboard(name,key,down,x,y)
  287. if key == 32 and data[name].fly < os.time()-1800 then
  288. v=_Vento*10
  289.  
  290. tfm.exec.movePlayer(name,0,0,false,0,-v*3,true)
  291. data[name].fly=os.time();
  292. end
  293. end
  294.  
  295. for all in pairs(tfm.get.room.playerList) do
  296. eventNewPlayer(all)
  297. end
  298.  
  299. sendNewMap()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement