Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Box={type=12, width=2000, height=10, foreground=true, friction=0.3, restitution=0.2, angle=0, color="0x6a7495", miceCollision=true, groundCollision=false}
- data={}
- id={}
- myObj={}
- obj={}
- x={}
- y={}
- checkCoords={}
- wait={}
- --395 -185
- --Skill = (W/L + W/(W+L) - L/W/10)*100 + (W+L)/100
- 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" />'}
- function updateMap()
- tfm.exec.addPhysicObject(1, 396, -166, Box)
- tfm.exec.addPhysicObject(2, 396, -210, Box)
- Box.angle=90
- Box.width=30
- tfm.exec.addPhysicObject(3, 0, -185, Box)
- tfm.exec.addPhysicObject(4, 1800, -186, Box)
- Box.angle=0
- Box.width=3000
- Box.height=150
- Box.miceCollision=false
- tfm.exec.addPhysicObject(5, 420, -229, Box)
- Box.miceCollision=true
- Box.width=3000
- Box.height=10
- tfm.exec.setUIMapName("#<R>Transform<J>ice!<N>")
- end
- function chooseObj(playerName)
- ui.addTextArea(1,"<p align='center'><font size='15'>Выберите свой объект!</font></p>",playerName,205,101,400,200,0x6a7495,0x000000,1,true)
- 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)
- 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)
- 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)
- 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)
- 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)
- 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)
- 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)
- 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)
- 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)
- end
- function openProfile(playerName, s1)
- if myObj[playerName].id==3 or myObj[playerName].id==4 then
- myObj[playerName].sizeY=1
- s2=1
- else
- myObj[playerName].sizeY=myObj[playerName].size
- s2=s1
- end
- if myObj[playerName].size>=200 then
- myObj[playerName].size=140
- s1=myObj[playerName].size
- end
- s1=295-(s1/2)
- s2=325-(s2/2)
- ui.addTextArea(11, "", playerName, 200, 35, 400, 350, 0x324650, 0x324650, 1)
- ui.addTextArea(12, "<p align='center'><b><font face='soopafresh' size='24'>"..playerName.."</font></b></p>", playerName, 200, 35, 400, 30, 0x324650, 0x324650, 1)
- 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)
- ui.addTextArea(14, "<p align='left'><b>Дата регистрации: <font size='9'>"..data[playerName].regDate.."</font></b></p>", playerName, 200, 110, 220, 20, 0x324650, 0x324650, 1)
- ui.addTextArea(15, "<p align='left'><b>Сыра собрано: "..data[playerName].wins.."</b></p>", playerName, 200, 140, 200, 20, 0x324650, 0x324650, 1)
- ui.addTextArea(16, "<p align='left'><b>Смертей: "..data[playerName].loses.."</b></p>", playerName, 200, 170, 200, 20, 0x324650, 0x324650, 1)
- ui.addTextArea(17, "<p align='left'><b>Раундов сыграно: "..data[playerName].rounds.."</b></p>", playerName, 200, 200, 200, 20, 0x324650, 0x324650, 1)
- ui.addTextArea(18, "<p align='left'><b>Превращений: "..data[playerName].transforms.."</b></p>", playerName, 200, 230, 200, 20, 0x324650, 0x324650, 1)
- ui.addTextArea(19, "<p align='center'><b>Открытые титулы:</b></p>", playerName, 400, 110, 200, 20, 0x324650, 0x324650, 1)
- ui.addTextArea(20, "<p align='center'><b>Медали:</b></p>", playerName, 400, 260, 200, 20, 0x324650, 0x324650, 1)
- 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)
- ui.addTextArea(22, "", playerName, s1, s2, myObj[playerName].size, myObj[playerName].sizeY, 0xffffff, 0xffffff, 0.5)
- ui.addTextArea(23, "<p align='center'><b></b></p>", playerName, 400, 110, 1, 260, 0x405763, 0x405763, 1)
- ui.addTextArea(24, "<p align='center'><b></b></p>", playerName, 200, 255, 400, 1, 0x405763, 0x405763, 1)
- ui.addTextArea(25, "<p align='center'><b></b></p>", playerName, 200, 105, 400, 1, 0x405763, 0x405763, 1)
- ui.addTextArea(26, "<p align='center'><a href='event:closeProfile'><b>Закрыть</b></a></p>", playerName, 200, 370, 400, 17, 0x324650, 0x405763, 1)
- -------------------------------------------------------------------------------------------------------------------------------------------------
- ui.addTextArea(27, "", playerName, 25, 55, 150, 100, 0x324650, 0x324650, 1)
- 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)
- 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)
- 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)
- end
- function closeObj(playerName)
- if myObj[playerName].size==140 and myObj[playerName].id==4 then
- myObj[playerName].size=200
- end
- for i,id in ipairs({1,2,3,4,5,6,7,8,9,10}) do
- ui.removeTextArea(id, playerName)
- end
- end
- function closeProfile(playerName)
- myObj[playerName].sizeY=nil
- 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
- ui.removeTextArea(id, playerName)
- end
- end
- --[[function invObj(playerName, s1, s2)
- myObj[playerName].x=295-(s1/2)
- if s2==nil then
- s2=s1
- end
- myObj[playerName].y=325-(s2/2)
- if myObj[playerName].profile==true then
- ui.addTextArea(22, "<p align='center'><b></b></p>", playerName, myObj[playerName].x, myObj[playerName].y, s1, s2, 0xffffff, 0xffffff, 0.5)
- end
- end]]
- function transform(playerName, x, y)
- tfm.exec.movePlayer(playerName, x, -185)
- obj[playerName]=tfm.exec.addShamanObject(myObj[playerName].id, x, y, 0, 0, 0, false)
- checkCoords[playerName]=true
- data[playerName].transforms=data[playerName].transforms+1
- end
- function getRegDate()
- function getMonth()
- for i, k in pairs(months) do
- month=string.match(date, i)
- if month~=nil then
- month=k
- return month
- end
- end
- end
- 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"}
- date=os.date("!*t")
- day=string.sub(date, string.find(date, "([%d]+)"))
- month1=getMonth()
- year=string.match(date, "%d%d%d%d")
- newDate=day.."/"..month1.."/"..year
- return newDate
- end
- function eventPlayerWon(playerName, timeElapsed, timeElapsedSinceRespawn)
- data[playerName].wins=data[playerName].wins+1
- myObj[playerName].profile="waiting"
- end
- function eventPlayerDied(playerName)
- data[playerName].loses=data[playerName].loses+1
- myObj[playerName].profile="waiting"
- end
- function eventTextAreaCallback(id,name,callback)
- if callback=="ball" then
- myObj[name].id=6
- myObj[name].size=30
- myObj[name].name="Мячик"
- closeObj(name)
- end
- if callback=="small box" then
- myObj[name].id=1
- myObj[name].size=30
- myObj[name].name="Маленький ящик"
- closeObj(name)
- end
- if callback=="big box" then
- myObj[name].id=2
- myObj[name].size=60
- myObj[name].name="Большой ящик"
- closeObj(name)
- end
- if callback=="big plank" then
- myObj[name].id=4
- myObj[name].size=200
- myObj[name].name="Большая палка"
- closeObj(name)
- end
- if callback=="small plank" then
- myObj[name].id=3
- myObj[name].size=100
- myObj[name].name="Маленькая палка"
- closeObj(name)
- end
- if callback=="anvil" then
- myObj[name].id=10
- myObj[name].size=30
- myObj[name].name="Наковальня"
- closeObj(name)
- end
- if callback=="cannon ball" then
- myObj[name].id=17
- myObj[name].size=30
- myObj[name].name="Ядро"
- closeObj(name)
- end
- if callback=="apple" then
- myObj[name].id=39
- myObj[name].size=30
- myObj[name].name="Яблоко"
- closeObj(name)
- end
- if callback=="icemice" then
- myObj[name].id=54
- myObj[name].size=60
- myObj[name].name="Куб льда"
- closeObj(name)
- end
- if callback=="closeProfile" then
- closeProfile(name)
- myObj[name].profile=false
- end
- if callback=="chooseobj" then
- chooseObj(name)
- closeProfile(name)
- end
- end
- function eventKeyboard(playerName, keyCode, down, xPosition, yPosition)
- 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
- transform(playerName, xPosition, yPosition)
- wait[playerName]=os.time()
- elseif keyCode==32 and xPosition~=0 and yPosition~=0 and checkCoords[playerName]==true and os.time() - wait[playerName] >= 1000 then
- x[playerName] = tfm.get.room.objectList[obj[playerName]].x
- y[playerName] = tfm.get.room.objectList[obj[playerName]].y
- tfm.exec.removeObject(obj[playerName])
- tfm.exec.movePlayer(playerName, x[playerName], y[playerName])
- x[playerName]=nil
- y[playerName]=nil
- checkCoords[playerName]=nil
- obj[playerName]=nil
- wait[playerName]=os.time()
- end
- if keyCode==80 and myObj[playerName].size~=nil then
- myObj[playerName].sizeY=nil
- openProfile(playerName, myObj[playerName].size, myObj[playerName].sizeY)
- end
- end
- function eventChatCommand(playerName, msg)
- local args={}
- for argument in msg:gmatch("[^#]+") do
- table.insert(args,argument)
- end
- --if msg:sub(0,4)=="stat" and args[2]~=nil then
- --print("Имя: "..data[args[2]].name)
- --print("Побед: "..data[args[2]].wins)
- --print("Поражений: "..data[args[2]].loses)
- --print("Раундов сыграно: "..data[args[2]].rounds)
- --print("Превращений: "..data[args[2]].transforms)
- --end
- end
- function eventNewPlayer(playerName)
- updateMap()
- if data[playerName]==nil then
- data[playerName]={}
- data[playerName].regDate=getRegDate()
- data[playerName].name=playerName
- data[playerName].wins=0
- data[playerName].loses=0
- data[playerName].rounds=0
- data[playerName].transforms=0
- myObj[playerName]={}
- myObj[playerName].profile="waiting"
- chooseObj(playerName)
- end
- tfm.exec.bindKeyboard(playerName, 32, true, true)
- tfm.exec.bindKeyboard(playerName, 80, true, true)
- wait[playerName]=os.time()
- if id[playerName]==nil then
- table.insert(id,playerName)
- id[playerName]=table.IndexOf(id, playerName)
- end
- end
- function eventNewGame()
- for name, p in pairs(tfm.get.room.playerList) do
- data[name].rounds=data[name].rounds+1
- wait[name]=0
- x[name]=nil
- y[name]=nil
- checkCoords[name]=nil
- obj[name]=nil
- end
- updateMap()
- end
- --function eventLoop(a, timleft)
- --for name, p in pairs(tfm.get.room.playerList) do
- --if checkCoords[name]==true then
- --x[name] = tfm.get.room.objectList[obj[name]].x
- --y[name] = tfm.get.room.objectList[obj[name]].y
- --end
- --end
- --end
- table.IndexOf=function(t, value)
- for i, v in ipairs(t) do
- if v==value then
- return i
- end
- end
- return false
- end
- for name, p in pairs(tfm.get.room.playerList) do
- eventNewPlayer(name)
- end
- tfm.exec.newGame()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement