Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Forum topic : http://www.transformice.com/forum/?s=467513&p=0
- tfm.exec.disableAutoNewGame(true)
- tfm.exec.disableAutoShaman(true)
- tfm.exec.disableAutoTimeLeft(true)
- players={}
- toDespawn={}
- maps={4007168,2113338,4062696,2818947,1822822,4012245,159709,3999440,3583744,3998852,3997006,743739,467799,139501,172357}
- tfm.exec.setGameTime(120)
- tfm.exec.setUIShamanName("<font color='#F0B92E'>CloudGame</font>")
- function eventNewPlayer(name)
- for i,key in ipairs({32,40,83}) do
- tfm.exec.bindKeyboard(name,key,true,true)
- end
- players[name]={
- timestamp=os.time(),
- offsets={x=2, y=10}
- }
- end
- function eventKeyboard(name,key,down,x,y)
- if (key==32 or key==40 or key==83) and started then
- if players[name].timestamp < os.time()-1000 then
- local id
- if tfm.get.room.playerList[name].isFacingRight then
- id=tfm.exec.addShamanObject(57,x+players[name].offsets.x,y+players[name].offsets.y)
- else
- id=tfm.exec.addShamanObject(57,x+players[name].offsets.x,y+players[name].offsets.y)
- end
- players[name].timestamp=os.time()
- table.insert(toDespawn,{os.time(),id})
- end
- end
- end
- function eventChatCommand(name,command)
- local arg={}
- for argument in command:gmatch("[^%s]+") do
- table.insert(arg,argument)
- end
- if arg[1]=="off" then
- if tonumber(arg[2]) and tonumber(arg[3]) then
- players[name].offsets={x=tonumber(arg[2]), tonumber(arg[3])}
- else
- players[name].offsets={x=2, y=10}
- end
- tfm.exec.chatMessage("Offsets changed to X:"..players[name].offsets.x.." Y:"..players[name].offsets.y,name)
- end
- end
- function eventNewGame()
- started=false
- end
- function eventLoop(time,remaining)
- if time >= 3000 and not started then
- started=true
- end
- if remaining<=0 then
- tfm.exec.newGame(maps[math.random(#maps)])
- end
- for i,cannon in ipairs(toDespawn) do
- if cannon[1] <= os.time()-3000 then
- tfm.exec.removeObject(cannon[2])
- table.remove(toDespawn,i)
- end
- end
- end
- function eventPlayerDied(name)
- local i=0
- local n
- for pname,player in pairs(tfm.get.room.playerList) do
- if not player.isDead then
- i=i+1
- n=pname
- end
- end
- if i==0 then
- tfm.exec.newGame(maps[math.random(#maps)])
- elseif i==1 then
- tfm.exec.giveCheese(n)
- tfm.exec.playerVictory(n)
- end
- end
- for name,player in pairs(tfm.get.room.playerList) do
- eventNewPlayer(name)
- end
- function eventPlayerDied(playerName)
- tfm.exec.respawnPlayer(playerName)
- end
- tfm.exec.setNameColor("Clowfish","Clowfish", 0xA2FE00)
- ui.addPopup(1,3,"<B>Ты в комнате #Cloud. Помощь - !help.<B>",player,300,100,200)
- admins={Clowfish=true, Clowfish=true}
- function isAdmin(name)
- return (admins[name] or false)
- end
- function main()
- command.addHandler("map", map);
- end
- function map(player, code)
- if isAdmin(player) then
- tfm.exec.newGame(code)
- end
- end
- function eventChatCommand(player, message)
- local args = string.split(message, "%s")
- local text = table.remove(args, 1)
- command.handle(string.lower(text), player, args)
- end
- command = {handlers = {}}
- function command.addHandler(text, handler)
- if command.handlers[text] == nil then
- command.handlers[text] = {}
- end
- table.insert(command.handlers[text], handler)
- end
- function command.removeHandler(text, handler)
- if command.handlers[text] ~= nil then
- local index
- for i, h in ipairs(command.handlers[text]) do
- if handler == h then
- index = i
- end
- end
- if index ~= nil then
- table.remove(command.handlers[text], index)
- if #command.handlers[text] == 0 then
- command.handlers[text] = nil
- end
- end
- end
- end
- function command.handle(text, player, args)
- if command.handlers[text] ~= nil then
- for i, handler in ipairs(command.handlers[text]) do
- handler(player, unpack(args))
- end
- end
- end
- function string.split(str, s)
- local res = {};
- for part in string.gmatch(str, "[^" .. s .. "]+") do
- table.insert(res, part)
- end
- return res;
- end
- function unpack (t, i)
- i = i or 1
- if t[i] ~= nil then
- return t[i], unpack(t, i + 1)
- end
- end
- main();
- function eventChatCommand(playerName, command)
- if command=="help" then
- ui.addPopup(2,0,"Привет! Это новая мини-игра, управляй облаками(кнопка вниз), первый дойди до норы вместе с сыром!",playerName,220,180,360);
- end
- end
- function eventPlayerWon(playerName)
- tfm.exec.newGame(maps[math.random(#maps)])
- ui.addTextArea(1,"<J>"..playerName.."<N> выиграл!",NIL,10,30)
- tfm.exec.newGame(maps[math.random(#maps)])
- function
- tfm.exec.playerVictory(playerName)
- tfm.exec.killPlayer(playerName)
- end
- end
- tfm.exec.newGame(maps[math.random(#maps)])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement