Advertisement
Guest User

vo.5

a guest
Feb 10th, 2015
267
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 11.36 KB | None | 0 0
  1. Box={type=12, width=2000, height=10, foreground=true, friction=0.3, restitution=0.2, angle=0, color="0x6a7495", miceCollision=true, groundCollision=false}
  2. data={}
  3. id={}
  4. myObj={}
  5. obj={}
  6. x={}
  7. y={}
  8. checkCoords={}
  9. wait={}
  10. --395 -185
  11. box={'<S><S X="396" L="30" o="6a7495" H="10" c="3" Y="-166" T="12" P="0,0,0.3,0.2,0,0,0,0" /><S P="0,0,0.3,0.2,90,0,0,0" L="30" o="6a7495" X="376" c="3" Y="-185" T="12" H="10" /><S H="10" L="30" o="6a7495" X="416" c="3" Y="-186" T="12" P="0,0,0.3,0.2,90,0,0,0" /><S P="0,0,0.3,0.2,0,0,0,0" L="30" o="6a7495" H="10" c="3" Y="-205" T="12" X="396" /><S P="0,0,0.3,0.2,0,0,0,0" L="794" o="6a7495" X="420" c="3" N="" Y="-229" T="12" H="150" />'}
  12.  
  13. function updateMap()
  14. tfm.exec.addPhysicObject(1, 396, -166, Box)
  15. tfm.exec.addPhysicObject(2, 396, -210, Box)
  16. Box["angle"]=90
  17. Box["width"]=30
  18. tfm.exec.addPhysicObject(3, 0, -185, Box)
  19. tfm.exec.addPhysicObject(4, 1800, -186, Box)
  20. Box["angle"]=0
  21. Box["width"]=3000
  22. Box["height"]=150
  23. Box["miceCollision"]=false
  24. tfm.exec.addPhysicObject(5, 420, -229, Box)
  25. Box["miceCollision"]=true
  26. Box["width"]=3000
  27. Box["height"]=10
  28. tfm.exec.setUIMapName("#<R>Transform<J>ice!<N>")
  29. end
  30.  
  31. function chooseObj(playerName)
  32. ui.addTextArea(1,"<p align='center'><font size='15'>Выберите свой объект!</font></p>",playerName,205,101,400,200,0x6a7495,0x000000,1,true)
  33. ui.addTextArea(2,"<p align='center'><a href='event:ball'> <font size='15'>Мяч</font></a></p>",playerName,215,151,100,25,0x000033,0x000000,0.3,true)
  34. ui.addTextArea(3,"<p align='center'><a href='event:small box'> <font size='15'>Мал. ящик</font></a></p>",playerName,355,151,100,25,0x000033,0x000000,0.3,true)
  35. ui.addTextArea(4,"<p align='center'><a href='event:big box'> <font size='15'>Бол. ящик</font></a></p>",playerName,495,151,100,25,0x000033,0x000000,0.3,true)
  36. ui.addTextArea(5,"<p align='center'><a href='event:big plank'> <font size='15'>Бол. палка</font></a></p>",playerName,215,201,100,25,0x000033,0x000000,0.3,true)
  37. ui.addTextArea(6,"<p align='center'><a href='event:small plank'> <font size='15'>Мал. палка</font></a></p>",playerName,355,201,100,25,0x000033,0x000000,0.3,true)
  38. ui.addTextArea(7,"<p align='center'><a href='event:anvil'> <font size='14'>Наковальня</font></a></p>",playerName,495,201,100,25,0x000033,0x000000,0.3,true)
  39. ui.addTextArea(8,"<p align='center'><a href='event:cannon ball'> <font size='15'>Ядро</font></a></p>",playerName,215,251,100,25,0x000033,0x000000,0.3,true)
  40. ui.addTextArea(9,"<p align='center'><a href='event:apple'> <font size='15'>Яблоко</font></a></p>",playerName,355,251,100,25,0x000033,0x000000,0.3,true)
  41. ui.addTextArea(10,"<p align='center'><a href='event:icemice'> <font size='15'>Куб льда</font></a></p>",playerName,495,251,100,25,0x000033,0x000000,0.3,true)
  42. end
  43.  
  44. function openProfile(playerName, s1, s2)
  45. if myObj[playerName].size>=200 then
  46. myObj[playerName].size=140
  47. s1=myObj[playerName].size
  48. end
  49. if s2==nil then
  50. s2=s1
  51. myObj[playerName].sizeY=myObj[playerName].size
  52. end
  53. s1=295-(s1/2)
  54. s2=325-(s2/2)
  55. ui.addTextArea(11, "", playerName, 200, 35, 400, 350, 0x324650, 0x324650, 1)
  56. ui.addTextArea(12, "<p align='center'><b><font face='soopafresh' size='24'>"..playerName.."</font></b></p>", playerName, 200, 35, 400, 30, 0x324650, 0x324650, 1)
  57. ui.addTextArea(13, "<p align='center'><b><font face='soopafresh' size='16'>Little mouse</font></b></p>", playerName, 200, 70, 400, 25, 0x324650, 0x324650, 1)
  58. ui.addTextArea(14, "<p align='left'><b>Дата регистрации: <font size='9'>"..data[playerName].regDate.."</font></b></p>", playerName, 200, 110, 220, 20, 0x324650, 0x324650, 1)
  59. ui.addTextArea(15, "<p align='left'><b>Сыра собрано: "..data[playerName].wins.."</b></p>", playerName, 200, 140, 200, 20, 0x324650, 0x324650, 1)
  60. ui.addTextArea(16, "<p align='left'><b>Смертей: "..data[playerName].loses.."</b></p>", playerName, 200, 170, 200, 20, 0x324650, 0x324650, 1)
  61. ui.addTextArea(17, "<p align='left'><b>Раундов сыграно: "..data[playerName].rounds.."</b></p>", playerName, 200, 200, 200, 20, 0x324650, 0x324650, 1)
  62. ui.addTextArea(18, "<p align='left'><b>Превращений: "..data[playerName].transforms.."</b></p>", playerName, 200, 230, 200, 20, 0x324650, 0x324650, 1)
  63. ui.addTextArea(19, "<p align='center'><b>Открытые титулы:</b></p>", playerName, 400, 110, 200, 20, 0x324650, 0x324650, 1)
  64. ui.addTextArea(20, "<p align='center'><b>Медали:</b></p>", playerName, 400, 260, 200, 20, 0x324650, 0x324650, 1)
  65. ui.addTextArea(21, "<p align='center'><b>Текущий объект:<a href='event:'></b><br><font size='10' color='#A4CF9E'>"..myObj[playerName].name.."</a></font></p>", playerName, 200, 260, 190, 40, 0x324650, 0x324650, 1)
  66. ui.addTextArea(22, "<p align='center'><b></b></p>", playerName, s1, s2, myObj[playerName].size, myObj[playerName].sizeY, 0xffffff, 0xffffff, 0.5)
  67. ui.addTextArea(23, "<p align='center'><b></b></p>", playerName, 400, 110, 1, 260, 0x405763, 0x405763, 1)
  68. ui.addTextArea(24, "<p align='center'><b></b></p>", playerName, 200, 255, 400, 1, 0x405763, 0x405763, 1)
  69. ui.addTextArea(25, "<p align='center'><b></b></p>", playerName, 200, 105, 400, 1, 0x405763, 0x405763, 1)
  70. ui.addTextArea(26, "<p align='center'><a href='event:closeProfile'><b>Закрыть</b></a></p>", playerName, 200, 370, 400, 17, 0x324650, 0x405763, 1)
  71. end
  72.  
  73. function closeObj(playerName)
  74.     if myObj[playerName].size==140 and myObj[playerName].id==4 then
  75.         myObj[playerName].size=200
  76.     end
  77.     for i,id in ipairs({1,2,3,4,5,6,7,8,9,10}) do
  78.         ui.removeTextArea(id, playerName)
  79.     end
  80. end
  81.  
  82. function closeProfile(playerName)
  83.     for i,id in ipairs({11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26}) do
  84.         ui.removeTextArea(id, playerName)
  85.     end
  86. end
  87.  
  88. --[[function invObj(playerName, s1, s2)
  89. myObj[playerName].x=295-(s1/2)
  90. if s2==nil then
  91. s2=s1
  92. end
  93. myObj[playerName].y=325-(s2/2)
  94. if myObj[playerName].profile==true then
  95.     ui.addTextArea(22, "<p align='center'><b></b></p>", playerName, myObj[playerName].x, myObj[playerName].y, s1, s2, 0xffffff, 0xffffff, 0.5)
  96. end
  97. end]]
  98.  
  99. function transform(playerName)
  100. x[playerName]=tfm.get.room.playerList[playerName].x
  101. y[playerName]=tfm.get.room.playerList[playerName].y
  102. tfm.exec.movePlayer(playerName, x[playerName], -185)
  103. obj[playerName]=tfm.exec.addShamanObject(myObj[playerName].id, x[playerName], y[playerName], 0, 0, 0, false)
  104. checkCoords[playerName]=true
  105. data[playerName].transforms=data[playerName].transforms+1
  106. end
  107.  
  108. function getRegDate()
  109. function getMonth()
  110.     for i, k in pairs(months) do
  111.         month=string.match(date, i)
  112.         if month~=nil then
  113.             month=k
  114.             return month
  115.         end
  116.     end
  117. end
  118. months={["Jan"]="01",["Feb"]="02",["Mar"]="03",["Apr"]="04",["May"]="05",["Jun"]="06",["Jul"]="07",["Aug"]="08",["Sep"]="09",["Oct"]="10",["Nov"]="11",["Dec"]="12"}
  119. date=os.date("!*t")
  120. day=string.sub(date, string.find(date, "([%d]+)"))
  121. month1=getMonth()
  122. year=string.match(date, "%d%d%d%d")
  123. newDate=day.."/"..month1.."/"..year
  124. return newDate
  125. end
  126.  
  127. function eventPlayerWon(playerName, timeElapsed, timeElapsedSinceRespawn)
  128. data[playerName].wins=data[playerName].wins+1
  129. myObj[playerName].profile="waiting"
  130. end
  131.  
  132. function eventPlayerDied(playerName)
  133. data[playerName].loses=data[playerName].loses+1
  134. myObj[playerName].profile="waiting"
  135. end
  136.  
  137. function eventTextAreaCallback(id,name,callback)
  138.     if callback=="ball" then
  139.         myObj[name].id=6
  140.         myObj[name].size=30
  141.         myObj[name].name="Мячик"
  142.         closeObj(name)
  143.     end
  144.     if callback=="small box" then
  145.         myObj[name].id=1
  146.         myObj[name].size=30
  147.         myObj[name].name="Маленький ящик"
  148.         closeObj(name) 
  149.     end
  150.     if callback=="big box" then
  151.         myObj[name].id=2
  152.         myObj[name].size=60
  153.         myObj[name].name="Большой ящик"
  154.         closeObj(name) 
  155.     end
  156.     if callback=="big plank" then
  157.         myObj[name].id=4
  158.         myObj[name].size=200
  159.         myObj[name].sizeY=1
  160.         myObj[name].name="Большая палка"
  161.         closeObj(name) 
  162.     end
  163.     if callback=="small plank" then
  164.         myObj[name].id=3
  165.         myObj[name].size=100
  166.         myObj[name].sizeY=1
  167.         myObj[name].name="Маленькая палка"
  168.         closeObj(name) 
  169.     end
  170.     if callback=="anvil" then
  171.         myObj[name].id=10
  172.         myObj[name].size=30
  173.         myObj[name].name="Наковальня"
  174.         closeObj(name) 
  175.     end
  176.     if callback=="cannon ball" then
  177.         myObj[name].id=17
  178.         myObj[name].size=30
  179.         myObj[name].name="Ядро"
  180.         closeObj(name) 
  181.     end
  182.     if callback=="apple" then
  183.         myObj[name].id=39
  184.         myObj[name].size=30
  185.         myObj[name].name="Яблоко"
  186.         closeObj(name)
  187.     end
  188.     if callback=="icemice" then
  189.         myObj[name].id=54
  190.         myObj[name].size=60
  191.         myObj[name].name="Куб льда"
  192.         closeObj(name) 
  193.     end
  194.     if callback=="closeProfile" then
  195.         closeProfile(name)
  196.         myObj[name].profile=false
  197.     end
  198. end
  199.  
  200. function eventKeyboard(playerName, keyCode, down, xPosition, yPosition)
  201.     if keyCode==32 and xPosition~=0 and yPosition~=0 and myObj[playerName].id~=nil and checkCoords[playerName]~=true and os.time() - wait[playerName] >= 1000 then
  202.         transform(playerName)
  203.         wait[playerName]=os.time()
  204.     --end
  205.     --if keyCode==32 and checkCoords[playerName]==true then
  206.     elseif keyCode==32 and xPosition~=0 and yPosition~=0 and checkCoords[playerName]==true and os.time() - wait[playerName] >= 1000 then
  207.         tfm.exec.removeObject(obj[playerName])
  208.         tfm.exec.movePlayer(playerName, x[playerName], y[playerName])
  209.         x[playerName]=nil
  210.         y[playerName]=nil
  211.         checkCoords[playerName]=nil
  212.         obj[playerName]=nil
  213.         wait[playerName]=os.time()
  214.     end
  215.     if keyCode==80 and myObj[playerName].size~=nil then
  216.         openProfile(playerName, myObj[playerName].size, myObj[playerName].sizeY)
  217.     end
  218. end
  219.  
  220. function eventChatCommand(playerName, msg)
  221. local args={}
  222.     for argument in msg:gmatch("[^#]+") do
  223.         table.insert(args,argument)
  224.     end
  225.     if msg:sub(0,4)=="stat" and args[2]~=nil then
  226.         print("Имя: "..data[args[2]].name)
  227.         print("Побед: "..data[args[2]].wins)
  228.         print("Поражений: "..data[args[2]].loses)
  229.         print("Раундов сыграно: "..data[args[2]].rounds)
  230.         print("Превращений: "..data[args[2]].transforms)
  231.     end
  232. end
  233.  
  234. function eventNewPlayer(playerName)
  235. updateMap()
  236. if data[playerName]==nil then
  237. data[playerName]={}
  238. data[playerName].regDate=getRegDate()
  239. data[playerName].name=playerName
  240. data[playerName].wins=0
  241. data[playerName].loses=0
  242. data[playerName].rounds=0
  243. data[playerName].transforms=0
  244. myObj[playerName]={}
  245. myObj[playerName].profile="waiting"
  246. chooseObj(playerName)
  247. end
  248. tfm.exec.bindKeyboard(playerName, 32, true, true)
  249. tfm.exec.bindKeyboard(playerName, 80, true, true)
  250. wait[playerName]=os.time()
  251.     if id[playerName]==nil then
  252.         table.insert(id,playerName)
  253.         id[playerName]=table.IndexOf(id, playerName)
  254.     end
  255. end
  256.  
  257. function eventNewGame()
  258.     for name, p in pairs(tfm.get.room.playerList) do
  259.         data[name].rounds=data[name].rounds+1
  260.         wait[name]=0
  261.         x[name]=nil
  262.         y[name]=nil
  263.         checkCoords[name]=nil
  264.         obj[name]=nil
  265.     end
  266.         updateMap()
  267. end
  268.  
  269. function eventLoop(a, timleft)
  270.     for name, p in pairs(tfm.get.room.playerList) do
  271.         --[[if myObj[name].profile==true then
  272.             invObj(name, myObj[name].size, myObj[name].sizeY)
  273.             myObj[name].profile=false
  274.         end]]
  275.         if checkCoords[name]==true then
  276.             x[name] = tfm.get.room.objectList[obj[name]].x
  277.             y[name] = tfm.get.room.objectList[obj[name]].y
  278.         end
  279.     end
  280. end
  281.  
  282. table.IndexOf=function(t, value)
  283.     for i, v in ipairs(t) do
  284.         if v==value then
  285.             return i
  286.         end
  287.     end
  288. return false
  289. end
  290.  
  291. for name, p in pairs(tfm.get.room.playerList) do
  292.     eventNewPlayer(name)
  293. end
  294. tfm.exec.newGame()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement