Advertisement
Unlocker001_TFM

dklmakdam

Feb 18th, 2017
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.38 KB | None | 0 0
  1. maps = {
  2. "10","15","14", }
  3.  
  4. local keys = {space = 32}
  5. local places = 0
  6. local players = {}
  7.  
  8. local shop = {
  9. {n = "Meep (Spacebar to use)",
  10. cost = 25,
  11. effect = function(n)
  12. tfm.exec.giveMeep(n)
  13. end,
  14. },
  15. {n = "Speed (Spacebar to use)",
  16. cost = 60,
  17. effect = function(n)
  18. tfm.exec.bindKeyboard(n, keys.space, true, true)
  19. end,
  20. },
  21. }
  22.  
  23. function main()
  24. for n in pairs(tfm.get.room.playerList) do
  25. eventNewPlayer(n)
  26. end
  27. end
  28.  
  29. function newGame()
  30. local code = specialMaps[math.random(#specialMaps)]
  31. tfm.exec.newGame(code)
  32. end
  33.  
  34. function showShop(n)
  35. if players[n].openShop then
  36. local shopStr = ""
  37. for i, item in pairs(shop) do
  38. shopStr = "<a href='event:shop_"..i.."'>["..item.cost.."] "..item.n.."</a><br>"..shopStr
  39. end
  40.  
  41. ui.addTextArea(0, "<font size='12' face='Wingdings'><p align='center'><a href='event:close'><rose><a href='event:close'>z <font size='12' face='Calibri'>"..players[n].coins, n, 10, 30, 60, 19, 0x212e35, 0x5d7d90, 0.5, true)
  42. ui.addTextArea(1, "<br><br>"..shopStr, n, 250, 80, 300, 200, 0x324650, 0x5d7d90, 1, true)
  43. ui.addTextArea(2, "<font size='14' face='Calibri'><p align='center'>Shop", n, 250, 80, 298, 20, 0x212e35, 0x5d7d90, 1, true)
  44. ui.addTextArea(3, "<font size='16' face='Calibri'><p align='center'><a href='event:close'><v>X", n, 520, 78, 29, 29, 0x324650, 0x000000, 0, true)
  45. else
  46. ui.addTextArea(0, "<font size='12' face='Wingdings'><p align='center'><a href='event:close'><rose><a href='event:open'>z <font size='12' face='Calibri'>"..players[n].coins, n, 10, 30, 60, 19, 0x212e35, 0x5d7d90, 0.5, true)
  47. end
  48. end
  49.  
  50. function eventNewGame()
  51. places = 0
  52. end
  53.  
  54. function eventKeyboard(n, key, down, x, y)
  55. local data = tfm.get.room.playerList[n]
  56. if key == keys.space then
  57. local dir = data.isFacingRight and 1 or -1
  58.  
  59. tfm.exec.movePlayer(n, 0, 0, false, 80 * dir, 0, false)
  60. tfm.exec.bindKeyboard(n, keys.space, true, false)
  61. end
  62. end
  63.  
  64. function eventPlayerWon(n)
  65. local player = players[n]
  66.  
  67. places = places + 1
  68.  
  69. if places == 1 then
  70. player.coins = player.coins + 20
  71. elseif places == 2 then
  72. player.coins = player.coins + 15
  73. elseif places == 3 then
  74. player.coins = player.coins + 5
  75. end
  76. showShop(n)
  77. end
  78.  
  79. function eventNewPlayer(n)
  80. if not players[n] then
  81. players[n] = {
  82. coins = 0,
  83. openShop = false,
  84. }
  85. end
  86. showShop(n)
  87. end
  88.  
  89. function eventTextAreaCallback(id, n, cb)
  90. local player = players[n]
  91.  
  92. if cb == "close" then
  93. for i = 0, 3, 1 do
  94. ui.removeTextArea(i, n)
  95. end
  96. player.openShop = false
  97. elseif cb == "open" then
  98. player.openShop = true
  99. elseif cb:sub(1, 4) == "shop" then
  100. local i = tonumber(cb:sub(6))
  101. local item = shop[i]
  102. if item.cost <= player.coins then
  103. player.coins = player.coins - item.cost
  104. if item.effect then item.effect(n) end
  105. end
  106. end
  107. showShop(n)
  108. end
  109.  
  110. main()
  111. newGame()
  112. function eventPlayerDied(name)
  113. if not data[name].CheeseGhost then
  114. local i=0
  115. local n
  116. for pname,player in pairs(tfm.get.room.playerList) do
  117. if not player.isDead then
  118. i=i+1
  119. n=pname
  120. end
  121. end
  122. if i==0 then
  123. tfm.exec.setGameTime(2)
  124. elseif i==1 then
  125. tfm.exec.setGameTime(20)
  126. end
  127. else
  128. data[name].CheeseGhost=false
  129. end
  130. end
  131. tfm.exec.newGame(maps[math.random(#maps)])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement