Advertisement
Eshkation-

Untitled

Aug 26th, 2016
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.98 KB | None | 0 0
  1. tfm.exec.disableAutoNewGame()
  2. tfm.exec.newGame('<C><P /><Z><S><S c="4" L="3000" o="0" H="10" X="366" Y="197" T="13" P="0,0,0.3,0.2,0,0,0,0" /></S><D /><O /></Z></C>')
  3. local point = {}
  4. point.__index = point
  5.  
  6. local vertices = {}
  7. point1 = false
  8. id = 0
  9. area = 70
  10.  
  11. local choosenPoints = {}
  12.  
  13. function point.new(x, y, p)
  14. local options = {
  15. x = x,
  16. y = y,
  17. p = p or 13
  18. }
  19. local self = setmetatable(options, point)
  20. return self
  21. end
  22.  
  23. function point:display()
  24. tfm.exec.displayParticle(self.p, self.x*area, self.y*area, 0, 0, 0, 0)
  25. end
  26.  
  27. function desenhaTriangulo()
  28. vertices = {
  29. a = point.new(3, 1),
  30. b = point.new(7, 1),
  31. c = point.new(5, 4.46)
  32. }
  33. for k, pointV in pairs({"a", "b", "c"}) do
  34. if vertices[pointV] then
  35. ui.addTextArea(id, "<R>.", nil, vertices[pointV].x*area, vertices[pointV].y*area, nil, nil, 0, 0, 0, true)
  36. id = id+1
  37. else
  38. return
  39. end
  40. end
  41. end
  42.  
  43. function sorteiaVertice()
  44. if not point1 then
  45. point1 = point.new(10, 5.46, 9)
  46. end
  47. local sort = math.random(1, 6)
  48. local vertice = ""
  49. if sort == 1 or sort == 2 then
  50. vertice = "a"
  51. elseif sort == 3 or sort == 4 then
  52. vertice = "b"
  53. else
  54. vertice = "c"
  55. end
  56. --stfm.exec.chatMessage(string.format("<BL>Vertice sorteada: %s", vertice:upper()))
  57. local point2 = vertices[vertice]
  58. local pointmedia = point.new((point1.x+point2.x)/2, (point1.y+point2.y)/2, 9)
  59. table.insert(choosenPoints, pointmedia)
  60. point1 = table.copy(pointmedia)
  61. ui.addTextArea(id, string.format("<font color='#%s'>.", string.format("%x", math.random(0x000000, 0xFFFFFF))), nil, point1.x*area, point1.y*area, nil, nil, 0, 0, 0, true)
  62. id = id+1
  63. end
  64.  
  65. function table.copy(t)
  66. local t2 = {}
  67. for k, v in pairs(t) do
  68. t2[k] = v
  69. end
  70. return t2
  71. end
  72.  
  73. function notifyLoop()
  74. local tick = 20
  75. s = 1000/tick
  76. for t = 0, 1000 - s, s do
  77. system.newTimer(function ()
  78. system.newTimer(loop, 1000, true)
  79. end, 1000 + t, false)
  80. end
  81. end
  82.  
  83. function loop()
  84. sorteiaVertice()
  85. end
  86.  
  87. desenhaTriangulo()
  88. notifyLoop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement