• API
• FAQ
• Tools
• Archive
daily pastebin goal
43%
SHARE
TWEET

# Labirintus

a guest Mar 13th, 2018 60 Never
ENDING IN00days00hours00mins00secs

1. tfm.exec.disableAutoShaman(true)
2. tfm.exec.disableAutoNewGame(true)
3. tfm.exec.disableAfkDeath(true)
4.
5. place = 0
6.
7. function init_matrix(wD, hG)
8. local result = {}
9. for y = 0, hG - 1 do
10. for x = 0, wD - 1 do
11. result[y * wD + x] = 1
12. end
13. result[y * wD + 0] = 0
14. result[y * wD + wD - 1] = 0
15. end
16. for x = 0, wD - 1 do
17. result[0 * wD + x] = 0
18. result[(hG - 1) * wD + x] = 0
19. end
20. return result
21. end
22.
23. function setMap(matrix, wD, hG)
24. place = 0
25. xml = '<C><P H="740" Ca="" N="" L="2200" /><Z><S><S P="0,0,0.3,0.2,0,0,0,0" X="1201" L="2500" o="0" H="760" c="4" Y="367" T="12" /><S P="0,0,0.3,0.2,0,0,0,0" L="2200" o="0" H="40" X="1100" N="" Y="0" T="12" /><S P="0,0,0.3,0.2,0,0,0,0" L="2240" o="0" H="40" X="1100" N="" Y="760" T="12" /><S P="0,0,0.3,0.2,90,0,0,0" L="760" o="0" H="40" X="2200" N="" Y="360" T="12" /><S m="" P="0,0,0.3,0.2,90,0,0,0" L="760" o="0" H="40" X="0" N="" Y="360" T="12" />'
26. xmlEnd = '</S><D><DS Y="40" X="80" /><T X="2082" Y="735" D="" /><F Y="732" X="2080" /></D><O /></Z></C>'
27. color = string.format("%X", math.random(0x000000, 0xFFFFFF))
28. invColor = string.format("%06x", 0xffffff - tonumber(color, 16))
29. for y = 0, hG - 1 do
30. for x = 0, wD - 1 do
31. if matrix[y * wD + x] == 0 then
32. r = ""
33. else
34. angle = {0}
35. xml = xml..string.format('<S H="40" P="0,0,3,0.2,%s,0,0,0" L="40" X="%s" Y="%s" o="%s" T="12" />',angle[math.random(#angle)], x*40,y*40,color)
36. end
37. end
38. end
39. xml = xml..xmlEnd
40. tfm.exec.newGame(xml)
41. tfm.exec.setGameTime('330')
42. end
43.
44. function eventNewPlayer(p)
45. tfm.exec.respawnPlayer(p)
46. end
47.
48. function genMaze(matrix, wD, hG, x, y)
49. local r = math.random(0, 3)
50. matrix[y * wD + x] = 0
51. for i = 0, 3 do
52. local d = (i + r) % 4
53. local dx = 0
54. local dy = 0
55. if d == 0 then
56. dx = 1
57. elseif d == 1 then
58. dx = -1
59. elseif d == 2 then
60. dy = 1
61. else
62. dy = -1
63. end
64. local nx = x + dx
65. local ny = y + dy
66. local nx2 = nx + dx
67. local ny2 = ny + dy
68. if matrix[ny * wD + nx] == 1 then
69. if matrix[ny2 * wD + nx2] == 1 then
70. matrix[ny * wD + nx] = 0
71. genMaze(matrix, wD, hG, nx2, ny2)
72. end
73. end
74. end
75. end
76.
77. wD = 55
78. hG = 20
79.
80. function eventPlayerWon(p)
81. place = place+1
82. if place == 1 then
83. tfm.exec.setGameTime(10)
84. end
85. end
86.
87. function eventLoop(t,r)
88. if r <= 0 then
89. matrix = init_matrix(wD, hG)
90. genMaze(matrix, wD, hG, 2, 2)
91. matrix[wD + 2] = 0
92. matrix[(hG - 2) * wD + wD - 3] = 0
93. setMap(matrix, wD, hG)
94. end
95. end
96. tfm.exec.setGameTime(1)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy.

Top