Mousetat

Chicken down challenge

Jan 7th, 2017
275
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.48 KB | None | 0 0
  1. host="Reshman" -- Only host should be changed. /!\ QUOTATION MARKS ARE IMPORTANT.
  2. time=60
  3. ducks=50
  4. itemID=33
  5. ghostItem=false
  6.  
  7. function waiting()
  8. ui.removeTextArea(99,nil)
  9. ui.removeTextArea(66,nil)
  10. tfm.exec.disableAutoNewGame(true)
  11. tfm.exec.disableAutoShaman(true)
  12. tfm.exec.disableAutoScore(true)
  13. tfm.exec.disableAfkDeath(true)
  14. tfm.exec.newGame(3720251)
  15. tfm.exec.setUIMapName("Chicken Pooping Game: Waiting.. <font color='#6C77C1'>|</font> <font color='#C2C2DA'>Host: </font><font color='#98E2EB'>" ..host.. "</font>")
  16. tfm.exec.setGameTime(0, false)
  17. end
  18.  
  19. function picking()
  20. ui.addTextArea(97, "<p align='center'>Wait until the players are picked by the host.</p>" ,player,200,200,400,0,0x324650,0x212F36,1,true)
  21. ui.addPopup(96,2," Choose <b><font color='#2E72CB'>Player 2</font></b> (must be exact):",host,200,150,400,true)
  22. ui.addPopup(97,2," Choose <b><font color='#EB1D51'>Player 1</font></b> (must be exact):",host,200,150,400,true)
  23. ui.addTextArea(5, "<a href='event:reset'>Reset</a>" ,host,740,324,80,15,0x324650,0x212F36,1,true)
  24. ui.addTextArea(6, "<a href='event:help'>Help</a>" ,nil,740,370,80,15,0x324650,0x212F36,1,true)
  25. ui.addTextArea(7, "<a href='event:settings'>Settings</a>" ,host,740,347,80,15,0x324650,0x212F36,1,true)
  26. end
  27.  
  28. function settings()
  29. ui.addPopup(73,1," Do you want the item to be a ghost item?\n ",host,200,150,400,true)
  30. ui.addPopup(72,2," Type in an item ID to replace chicken:",host,200,150,400,true)
  31. ui.addPopup(71,2," Choose amount of ducks required to win:",host,200,150,400,true)
  32. ui.addPopup(70,2," Pick time (range: 0-117):",host,200,150,400,true)
  33. end
  34.  
  35. function loadGame()
  36. n = 0
  37. m = 0
  38. ui.removeTextArea(97,nil)
  39. tfm.exec.disableAutoNewGame(false)
  40. tfm.exec.setUIMapName("Chicken Pooping Game! <font color='#6C77C1'>|</font> <font color='#C2C2DA'>Host: </font><font color='#98E2EB'>" ..host.. "</font>")
  41. tfm.exec.setGameTime(time+3, true)
  42. tfm.exec.setNameColor(player1,0xEB1D51)
  43. tfm.exec.setNameColor(player2,0x2E72CB)
  44. ui.addTextArea(1, "<b>Player 1:\n" ..player1.. "</b>",nil,160,208,120,0,0x324650,0x212F36,0,true)
  45. ui.addTextArea(2, "<b>Chicken pooped:\n" ..n.. "</b>",nil,160,253,120,0,0x324650,0x212F36,0,true)
  46. ui.addTextArea(3, "<b>Player 2:\n" ..player2.. "</b>",nil,520,208,120,0,0x324650,0x212F36,0,true)
  47. ui.addTextArea(4, "<b>Chicken pooped:\n" ..m.. "</b>",nil,520,253,120,0,0x324650,0x212F36,0,true)
  48. tfm.exec.movePlayer(player1,220,145,false,0,0,false)
  49. tfm.exec.movePlayer(player2,580,145,false,0,0,false)
  50. tfm.exec.bindKeyboard(player1, 40, true, true)
  51. tfm.exec.bindKeyboard(player2, 83, true, true)
  52. function eventPlayerLeft(player)
  53. if player==player1 then
  54. tfm.exec.setGameTime(5, false)
  55. ui.addTextArea(66,"<p align='center'><font size='72' color='#EB1D51'>" ..player1.. "</font><font size='72' color='#C2C2DA'> has left the game. Game will restart.</p></font>",nil,0,200,800,0,0x324650,0x212F36,0,true)
  56. roundWon()
  57. elseif player==player2 then
  58. tfm.exec.setGameTime(5, false)
  59. ui.addTextArea(66,"<p align='center'><font size='72' color='#2E72CB'>" ..player2.. "</font><font size='72' color='#C2C2DA'> has left the game. Game will restart.</p></font>",nil,0,200,800,0,0x324650,0x212F36,0,true)
  60. roundWon()
  61. end
  62. end
  63. end
  64.  
  65. function roundWon()
  66. ui.removeTextArea(1,nil)
  67. ui.removeTextArea(2,nil)
  68. ui.removeTextArea(3,nil)
  69. ui.removeTextArea(4,nil)
  70. tfm.exec.bindKeyboard(player1, 40, true, false)
  71. tfm.exec.bindKeyboard(player2, 83, true, false)
  72. end
  73.  
  74. function update(id1,id2,number,playerName,var,loser,x,y)
  75. xFart = math.random(-20,20)+x
  76. yFart = math.random(10,25)+y
  77. ui.updateTextArea(id1,"<b>Player "..number..":\n" ..playerName.. "</b>",nil)
  78. ui.updateTextArea(id2,"<b>Chicken pooped:\n" ..var.. "</b>",nil)
  79. tfm.exec.addShamanObject(itemID, x, y+20, 0, 0, 20, ghostItem)
  80. tfm.exec.displayParticle(3, xFart, yFart, 0, 0, 0, 0, nil)
  81. if var==ducks then
  82. ui.addTextArea(99,"<p align='center'><font size='72' color='#BABD2F'>" ..playerName.. " won the game!</p></font>",nil,0,200,800,0,0x324650,0x212F36,0,true)
  83. tfm.exec.displayParticle(6, xFart, yFart, 0, 0, 0, 0, loser)
  84. tfm.exec.movePlayer(loser,400,-30,false,0,0,false)
  85. tfm.exec.setGameTime(5, false)
  86. roundWon()
  87. end
  88. end
  89.  
  90. function eventTextAreaCallback(textArea, player, callback)
  91. if textArea==5 then
  92. waiting()
  93. roundWon()
  94. picking()
  95. elseif textArea==6 then
  96. ui.addPopup(98,0,"<p align='center'><font size='32'>Instructions</font></p><font color='#EB1D51'>\n Player 1</font> presses on down arrow.\n<font color='#2E72CB'> Player 2</font> presses on 's' button.\n Goal is to reach " ..ducks.. " ducks in " ..time.. " seconds. Good luck!\n\n<p align='center'><font size='8'></a>Game made by Cyanny.</font>",player,200,130,400,true)
  97. elseif textArea==7 then
  98. tfm.exec.disableAutoNewGame(true)
  99. picking()
  100. settings()
  101. end
  102. end
  103.  
  104. function eventKeyboard(player, key, down, x, y)
  105. if key==40 then
  106. n = n + 1
  107. update(1,2,1,player1,n,player2,x,y)
  108. elseif key==83 then
  109. m = m + 1
  110. update(3,4,2,player2,m,player1,x,y)
  111. end
  112. end
  113.  
  114. function eventPopupAnswer(popUpId, host, answer)
  115. if popUpId==70 then
  116. time= answer
  117. end
  118. if popUpId==71 then
  119. ducks = tonumber(answer) -- THANK YOU SO MUCH, ABDELTIF
  120. end
  121. if popUpId==72 then
  122. itemID= answer
  123. end
  124. if popUpId==73 then
  125. if answer=="yes" then
  126. ghostItem = true
  127. elseif answer=="no" then
  128. ghostItem = false
  129. end
  130. end
  131. if popUpId==97 then
  132. player1 = answer
  133. end
  134. if popUpId==96 then
  135. player2 = answer
  136. loadGame()
  137. end
  138. end
  139.  
  140. function eventNewGame()
  141. waiting()
  142. roundWon()
  143. picking()
  144. end
  145.  
  146. function eventNewPlayer(player)
  147. print(player)
  148. tfm.exec.respawnPlayer(player)
  149. end
  150.  
  151. waiting()
  152. picking()
Advertisement
Add Comment
Please, Sign In to add comment