Advertisement
Guest User

v0.7

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