Advertisement
Guest User

Untitled

a guest
Sep 3rd, 2019
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.04 KB | None | 0 0
  1. -- settings
  2. tfm.exec.disableAutoTimeLeft(disable)
  3. tfm.exec.disableAfkDeath(disable)
  4. tfm.exec.disableAllShamanSkills(disable)
  5. tfm.exec.disableAutoScore(disable)
  6. tfm.exec.disableAutoNewGame(disable)
  7. tfm.exec.disableMortCommand(disable)
  8. tfm.exec.disableAutoShaman(disable)
  9. initialMap = "@7640468"
  10. tfm.exec.newGame(initialMap)
  11. roundStart = false
  12.  
  13. -- constants
  14. playerData = {}
  15.  
  16. -- functions
  17. findIndex = function(value, array)
  18. rArray = {}
  19. for i=1, #array do
  20. rArray[array[i]] = i
  21. end
  22. return rArray[value]
  23. end
  24.  
  25. pythag = function(x1,y1,x2,y2,range)
  26. return ((x1 - x2)^2 + (y1 - y2)^2 < range^2)
  27. end
  28.  
  29. generateCollectables = function(playerName)
  30. for i=1,4 do
  31. local randInt = math.random(1, #spawners.x)
  32. local index = #playerData[playerName].collectables.x
  33. playerData[playerName].collectables.x[index+1] = spawners.x[randInt]
  34. playerData[playerName].collectables.y[index+1] = spawners.y[randInt]
  35. end
  36. end
  37.  
  38. spawnCollectables = function(playerName)
  39. for i=1, #playerData[playerName].collectables.x do
  40. ui.addTextArea(500 + i-1, "?", playerName, playerData[playerName].collectables.x[i]-5, playerData[playerName].collectables.y[i]-5, 20, 20, 0x000000, 0x000001, 0, false)
  41. end
  42. end
  43.  
  44. createRing = function(playerName, x, y, r1, r2, alpha, fineness, i)
  45. num = 0
  46. while num <= 2*math.pi do
  47. ui.addTextArea(i, "", playerName, r1*math.cos(num)+x-r2/2, r1*math.sin(num)+y-r2/2, r2, r2, 0x000000, 0x000001, alpha, true)
  48. num = num + 2*math.pi/fineness
  49. if i then
  50. i = i + 1
  51. end
  52. end
  53. return i
  54. end
  55.  
  56. nightMode = function(playerName)
  57. i = 0
  58. x = 400
  59. y = 250
  60.  
  61. i = createRing(playerName, x, y, 90, 35, 0.5, 25, i)
  62. i = createRing(playerName, x, y, 120, 40, 0.66, 30, i)
  63. i = createRing(playerName, x, y, 160, 50, 0.83, 40, i)
  64.  
  65. ui.addTextArea(i, "", playerName, 545, 0, 255, 400, 0x000000, 0x000001, 1, true)
  66. i=i+1
  67. ui.addTextArea(i, "", playerName, 0, 0, 255, 400, 0x000000, 0x000001, 1, true)
  68. i=i+1
  69. ui.addTextArea(i, "", playerName, 0, 0, 800, 123, 0x000000, 0x000001, 1, true)
  70. i=i+1
  71. ui.addTextArea(i, "", playerName, 0, 375, 800, 25, 0x000000, 0x000001, 1, true)
  72. i=i+1
  73. end
  74.  
  75.  
  76.  
  77. -- events
  78. eventNewPlayer = function(playerName)
  79. if not playerData[playerName] then
  80. playerData[playerName] = {collectables = {x = {}, y = {}}}
  81. end
  82. tfm.exec.bindKeyboard(playerName, 40, true, true)
  83. tfm.exec.bindKeyboard(playerName, 83, true, true)
  84. nightMode(playerName)
  85. tfm.exec.setPlayerScore(playerName, 0, false)
  86. end
  87.  
  88. eventNewGame = function()
  89. local xml = (tfm.get.room.xmlMapInfo.xml or '<C><P /><Z><S /><D /><O /></Z></C>')
  90. spawners = {x = {},y = {}}
  91. if xml:find('<O') then -- creds to Ratufufu for finding the x and ys of the yellow nails
  92. for data in xml:gmatch('<O(.-)/>') do
  93. if data:find('C="22"') then
  94. spawners.x[#spawners.x + 1] = (tonumber(data:match('X="(.-)"')) or 0)
  95. spawners.y[#spawners.x + 1] = (tonumber(data:match('Y="(.-)"')) or 0)
  96. end
  97. end
  98. end
  99. for k, v in next, tfm.get.room.playerList do
  100. generateCollectables(v.playerName)
  101. spawnCollectables(v.playerName)
  102. tfm.exec.respawnPlayer(v.playerName)
  103. end
  104. roundStart = true
  105. end
  106.  
  107. eventKeyboard = function(playerName, keyCode, down)
  108. if keyCode == 40 or keyCode == 83 then
  109. for i=1, #playerData[playerName].collectables.x do
  110. if pythag(playerData[playerName].collectables.x[i], playerData[playerName].collectables.y[i], tfm.get.room.playerList[playerName].x, tfm.get.room.playerList[playerName].y, 40) then
  111. local randInt = math.random(1, #spawners.x)
  112. print(spawners.x[randInt] .. "," .. spawners.y[#spawners.x])
  113. playerData[playerName].collectables.x[i] = spawners.x[randInt]
  114. playerData[playerName].collectables.y[i] = spawners.y[randInt]
  115. print(randInt)
  116. ui.addTextArea(500 + i-1, "?", playerName, spawners.x[randInt]-5, spawners.y[randInt]-5, 20, 20, 0x000000, 0x000001, 0, false)
  117. tfm.exec.setPlayerScore(playerName, 1, true)
  118. end
  119. end
  120. end
  121. end
  122.  
  123. -- execution
  124. for k, v in next, tfm.get.room.playerList do
  125. eventNewPlayer(v.playerName)
  126. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement