Advertisement
Guest User

Lucky Doors - Alexunutrei

a guest
Apr 24th, 2015
181
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 5.73 KB | None | 0 0
  1. tfm.exec.disableAutoNewGame(true)
  2. tfm.exec.disableAutoShaman(true)
  3. tfm.exec.disableAutoScore(true)
  4. tfm.exec.disableAutoTimeLeft(true)
  5.  
  6.  
  7. wm=0
  8. ta=1
  9.  
  10. function ng()
  11. if wm==0 then
  12.  
  13. if ta==0 then
  14. ui.removeTextArea(0,nil)
  15. ui.removeTextArea(1,nil)
  16. ui.removeTextArea(2,nil)
  17. ui.removeTextArea(3,nil)
  18. ui.removeTextArea(4,nil)
  19. ui.removeTextArea(5,nil)
  20. ui.removeTextArea(6,nil)
  21. ui.removeTextArea(7,nil)
  22. ui.removeTextArea(8,nil)
  23. ui.removeTextArea(9,nil)
  24. ui.removeTextArea(10,nil)
  25. ui.removeTextArea(11,nil)
  26. end
  27.  
  28. map=math.random(5) --6 --math.random(6)
  29.  
  30. if map==oldmap then
  31.  
  32. ng()
  33.  
  34.  
  35.  
  36. elseif map==1 then
  37. tfm.exec.newGame(5845948)
  38. oldmap=1
  39.  
  40. tfm.exec.setGameTime(60)
  41.  
  42. l=30
  43. h=60
  44.  
  45. x1=400
  46. y1=35
  47.  
  48. x2=550
  49. y2=35
  50.  
  51. x3=700
  52. y3=35
  53.  
  54. x4=200
  55. y4=35
  56.  
  57. x5=400
  58. y5=173
  59.  
  60. x6=550
  61. y6=173
  62.  
  63. x7=700
  64. y7=173
  65.  
  66. x8=200
  67. y8=173
  68.  
  69. x9=235
  70. y9=297
  71.  
  72. x10=100
  73. y10=297
  74.  
  75. x11=425
  76. y11=297
  77.  
  78. x12=678
  79. y12=297
  80. ta=0
  81.  
  82.  
  83. elseif map==2 then
  84.  
  85. oldmap=2
  86. tfm.exec.newGame(5847513)
  87.  
  88.  
  89. tfm.exec.setGameTime(60)
  90.  
  91. l=30
  92. h=60
  93.  
  94. x1=315-25
  95. y1=208-25
  96.  
  97. x2=502-25
  98. y2=329-25
  99.  
  100. x3=331-25
  101. y3=329-25
  102.  
  103. x4=466-25
  104. y4=94-25
  105.  
  106.  
  107. x5=142-25
  108. y5=94-25
  109.  
  110. x6=141-25
  111. y6=329-25
  112.  
  113. x7=89-25
  114. y7=208-25
  115.  
  116. x8=728-25
  117. y8=329-25
  118.  
  119. x9=516-25
  120. y9=208-25
  121.  
  122. x10=723-25
  123. y10=94-25
  124.  
  125.  
  126. x11=697-25
  127. y11=208-25
  128.  
  129. x12=603-25
  130. y12=94-25
  131. ta=0
  132.  
  133.  
  134. elseif map==3 then
  135. oldmap=3
  136. tfm.exec.newGame(5847903)
  137.  
  138.  
  139. tfm.exec.setGameTime(60)
  140.  
  141. l=30
  142. h=60
  143.  
  144. x1=292
  145. y1=25
  146.  
  147. x2=600
  148. y2=12
  149.  
  150. x3=730
  151. y3=83
  152.  
  153. x4=50
  154. y4=107
  155.  
  156. x5=403
  157. y5=92
  158.  
  159. x6=497
  160. y6=147
  161.  
  162. x7=234
  163. y7=217
  164.  
  165. x8=139
  166. y8=165
  167.  
  168. x9=160
  169. y9=340
  170.  
  171. x10=50
  172. y10=340
  173.  
  174. x11=717
  175. y11=276
  176.  
  177. x12=500
  178. y12=340
  179. ta=0
  180.  
  181.  
  182. elseif map==4 then
  183. oldmap=4
  184. tfm.exec.newGame(5849091)
  185.  
  186. tfm.exec.setGameTime(60)
  187.  
  188. l=30
  189. h=60
  190.  
  191.  
  192. x1=134
  193. y1=313
  194.  
  195. x2=64
  196. y2=65
  197.  
  198. x3=685
  199. y3=313
  200.  
  201. x4=22
  202. y4=313
  203.  
  204. x5=263
  205. y5=65
  206.  
  207. x6=57
  208. y6=194
  209.  
  210. x7=360
  211. y7=194
  212.  
  213. x8=216
  214. y8=194
  215.  
  216. x9=501
  217. y9=65
  218.  
  219. x10=372
  220. y10=313
  221.  
  222. x11=717
  223. y11=194
  224.  
  225. x12=706
  226. y12=65
  227. ta=0
  228.  
  229.  
  230. elseif map==5 then
  231. oldmap=5
  232. tfm.exec.newGame(5849433)
  233. ta=1
  234.  
  235. tfm.exec.setGameTime(60)
  236.  
  237. l=58
  238. h=82
  239.  
  240. x1=141
  241. y1=63
  242.  
  243. x2=306
  244. y2=200
  245.  
  246. x3=483
  247. y3=200
  248.  
  249. x4=479
  250. y4=63
  251.  
  252. x5=305
  253. y5=63
  254.  
  255. x6=145
  256. y6=312
  257.  
  258. x7=483
  259. y7=312
  260.  
  261. x8=308
  262. y8=312
  263.  
  264. x9=640
  265. y9=200
  266.  
  267. x10=643
  268. y10=312
  269.  
  270. x11=638
  271. y11=63
  272.  
  273. x12=143
  274. y12=200
  275.  
  276.  
  277.  
  278. end
  279.  
  280. nm=[[<font size="30" face="Soopafresh" color="#000000">Lucky doors!</font>]]
  281. ui.addTextArea(98,nm,nil,6,30,nil,nil,nil,nil,0,true)
  282. nm=[[<font size="30" face="Soopafresh" color="#258FF6">Lucky doors!</font>]]
  283. ui.addTextArea(99,nm,nil,10,30,nil,nil,nil,nil,0,true)
  284. nm=[[<font size="12" face="Soopafresh" color="3F3F3F">by Alexunutrei</font>]]
  285. ui.addTextArea(100,nm,nil,50,65,nil,nil,nil,nil,0,true)
  286.  
  287. if ta==0 then
  288. ui.addTextArea(0,"",nil,x1,y1,l,h,BLUE,BLACK,0.5,false) --OK
  289. ui.addTextArea(1,"",nil,x2,y2,l,h,BLUE,BLACK,0.5,false) --OK
  290. ui.addTextArea(2,"",nil,x3,y3,l,h,BLUE,BLACK,0.5,false) --OK
  291. ui.addTextArea(3,"",nil,x4,y4,l,h,BLUE,BLACK,0.5,false) --OK
  292. ui.addTextArea(4,"",nil,x5,y5,l,h,BLUE,BLACK,0.5,false) --OK
  293. ui.addTextArea(5,"",nil,x6,y6,l,h,BLUE,BLACK,0.5,false) --OK
  294. ui.addTextArea(6,"",nil,x7,y7,l,h,BLUE,BLACK,0.5,false) --OK
  295. ui.addTextArea(7,"",nil,x8,y8,l,h,BLUE,BLACK,0.5,false) --OK
  296. ui.addTextArea(8,"",nil,x9,y9,l,h,BLUE,BLACK,0.5,false) --OK
  297. ui.addTextArea(9,"",nil,x10,y10,l,h,BLUE,BLACK,0.5,false) --OK
  298. ui.addTextArea(10,"",nil,x11,y11,l,h,BLUE,BLACK,0.5,false) --OK
  299. ui.addTextArea(11,"",nil,x12,y12,l,h,BLUE,BLACK,0.5,false) --OK
  300. end
  301. end
  302. if wm==1 then
  303. tfm.exec.newGame(0)
  304. end
  305. end
  306.  
  307. ng()
  308. tm=0
  309.  
  310. tfm.exec.setUIMapName("Lucky doors  |  Creator: Alexunutrei")
  311.  
  312. function eventLoop(t,g)
  313. tm=tm+1
  314.  
  315. if tm==120 then
  316. wons=0
  317. if win==1 then
  318. ui.removeTextArea(101)
  319. win=0
  320. end
  321. tm=0
  322. ng()
  323. end
  324. end
  325.  
  326.  
  327. function eventNewPlayer(name)
  328. --inst=[[<font size="15" align="centre" face="Soopafresh" color="3F3F3F">Instructiuni:</font>
  329. --<font size="12" face="Verdana" color="3F3F3F">Trebuie sa intri prin usi, apasand tasta SPACE, pana la branza si la gaura.</font>]]
  330. --ui.addPopup(999, 0, inst, name, 280, 150,240)
  331.  
  332. tfm.exec.setPlayerScore(name,0)
  333. tfm.exec.bindKeyboard(name,32,true,true)
  334. end
  335.  
  336. players={}
  337.  
  338. for name,player in pairs(tfm.get.room.playerList)do
  339. players[name]={score=0}
  340. eventNewPlayer(name)
  341. end
  342.  
  343. function eventKeyboard(name,key,down,x,y)
  344. if key==32 then
  345.  
  346. if x<x1+l and x>x1 and y>y1 and y<y1+h then tfm.exec.movePlayer(name,x8+x-x1,y8+y-y1)
  347. end
  348.  
  349. if x>x2 and x<x2+l and y>y2 and y<y2+h then tfm.exec.movePlayer(name,x10+x-x2,y10+y-y2)
  350. end
  351.  
  352. if x>x3 and x<x3+l and y>y3 and y<y3+h then tfm.exec.movePlayer(name,x4+x-x3,y4+y-y3)
  353. end
  354.  
  355. if x>x4 and x<x4+l and y>y4 and y<y4+h then tfm.exec.movePlayer(name,x11+x-x4,y11+y-y4)
  356. end
  357.  
  358. if x>x11 and x<x11+l and y>y11 and y<y11+h then tfm.exec.movePlayer(name,x3+x-x11,y3+y-y11)
  359. end
  360.  
  361. if x>x10 and x<x10+l and y>y10 and y<y10+h then tfm.exec.movePlayer(name,x5+x-x10,y5+y-y10)
  362. end
  363.  
  364. if x>x5 and x<x5+l and y>y5 and y<y5+h then tfm.exec.movePlayer(name,x8+x-x5,y8+y-y5)
  365. end
  366.  
  367. if x>x8 and x<x8+l and y>y8 and y<y8+h then tfm.exec.movePlayer(name,x1+x-x8,y1+y-y8)
  368. end
  369.  
  370. if x>x7 and x<x7+l and y>y7 and y<y7+h then tfm.exec.movePlayer(name,x1+x-x7,y1+y-y7)
  371. end
  372.  
  373. if x>x6 and x<x6+l and y>y6 and y<y6+h then tfm.exec.movePlayer(name,x4+x-x6,y4+y-y6)
  374. end
  375.  
  376. if x>x9 and x<x9+l and y>y9 and y<y9+h then tfm.exec.movePlayer(name,x6+x-x9,y6+y-y9)
  377. end
  378.  
  379. if x>x12 and x<x12+l and y>y12 and y<y12+h then tfm.exec.movePlayer(name,x7+x-x12,y7+y-y12)
  380. end
  381.  
  382. end
  383. end
  384.  
  385. wons=0
  386. win=0
  387.  
  388. function eventPlayerWon(name)
  389.         if wons==0 then
  390.                 tfm.exec.setPlayerScore(name,1,true)
  391.                 players[name].score=players[name].score+1
  392.                 ui.addTextArea(101,name.." won this round!",nil,10,25)
  393.                 win=1
  394.                 tfm.exec.setGameTime(10)
  395.                  tm=100
  396.                 if players[name].score==10 then
  397.                 wm=1
  398.                 end
  399.         end
  400.         wons=wons+1
  401. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement