Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local squares = {}
- local gameFinished = false
- local lastId = 0
- local mice = {}
- local players = 0
- local skipVotes = 0
- local text = 0
- local version = 0.2
- local help = "<br><font color='#DCD17A'> \> Bienvenido al laberinto!! Para escapar ve al cuadro rojo y preciona espacio dentro de el, debo advertirte que el camino no es fácil<br><font color='#F8883F'>\> Tienes un salto extra que puedes usar con espacio también , pero sólo uno por ronda! úsalo con sabiduría<br><font color='#DC9669'>\> Si el laberinto es demasiado para ti puedes usar el comando !skip para votar por cambiar de mapa (Se muestra arriba del mapa, ahí encontrarás el mínimo de votos para cambiar de mapa también)<br><font color='#BB79FF'> \> Version: "..version.."</font>"
- local welcome = "<br><font color='#26A247'>Bienvenido a #maze, para obtener información coloca !help</font><br><J>Minijuego en desarrollo</J>"
- function main()
- tfm.exec.disableAutoTimeLeft()
- tfm.exec.disableAutoShaman()
- tfm.exec.disableAfkDeath()
- tfm.exec.disableAutoNewGame()
- system.disableChatCommandDisplay("start")
- for name in next,tfm.get.room.playerList do
- eventNewPlayer(name)
- end
- end
- function render()
- local id = 0
- for i = 0,800,45 do
- for o = 0,400,45 do
- a = {id = id,x = i,y = o}
- table.insert(squares,a)
- id = id + 1
- end
- end
- end
- render()
- function eventNewGame()
- gameFinished = false
- skipVotes = 0
- for name in next,tfm.get.room.playerList do
- mice[name].vote = false
- mice[name].jump = false
- end
- end
- function eventNewPlayer(name)
- players = players +1
- lastId = lastId +1
- if not mice[name] then
- mice[name] = {
- id = lastId,
- vote = false,
- jump = false
- }
- tfm.exec.chatMessage(welcome,name)
- end
- end
- function eventPlayerLeft(name)
- players = players -1
- end
- function spawn_ground(id,x,y)
- if id == 8 or id == 154 then return end
- local angle
- local a = math.random(1,2)
- local angle = a == 1 and 90 or 0
- local body = {
- type = 0 ,
- width = 20 ,
- height = 35 ,
- friction = 0.35 ,
- angle = angle ,
- }
- if a == 1 then
- body.friction = 10
- body.type = 4
- else
- body.height = 40
- end
- tfm.exec.addPhysicObject(id,x+20,y+20,body)
- end
- function start()
- text = math.floor(players/3)
- tfm.exec.newGame('<C><P /><Z><S><S L="800" H="20" X="400" Y="390" T="0" P="0,0,0.3,0.2,0,0,0,0" /></S><D /><O /></Z></C>')
- for j =1,#squares,1 do
- --ui.addTextArea(j,"",nil,squares[j].x,squares[j].y,40,40,0x0010FC,0x000000,0.5)
- if j ~= 8 or j ~= 154 then
- local i = math.random(1,10)
- if i == 2 then
- spawn_ground(j,squares[j].x,squares[j].y)
- elseif i == 1 then
- spawn_ground(j,squares[j].x,squares[j].y)
- elseif i == 3 then
- spawn_ground(j,squares[j].x,squares[j].y)
- elseif i == 4 then
- spawn_ground(j,squares[j].x,squares[j].y)
- end
- end
- end
- ui.addTextArea(1000,"",nil,squares[8].x,squares[8].y,40,40,0x0010FC,0x000000,0.3,true)
- ui.addTextArea(1001,"",nil,squares[154].x,squares[154].y,40,40,0xFC0B00,0x000000,0.3,true)
- for name in next,tfm.get.room.playerList do
- tfm.exec.movePlayer(name,20,335)
- system.bindKeyboard(name,32,true)
- end
- end
- function eventPlayerWon(name)
- if not gameFinished then
- gameFinished = true
- tfm.exec.setGameTime(5)
- end
- end
- function eventKeyboard(name,key,down,px,py)
- if key == 32 then
- if px > squares[154].x and px < squares[154].x+40 then
- if py > squares[154].y and py < squares[154].y+40 then
- tfm.exec.giveCheese(name)
- tfm.exec.playerVictory(name)
- end
- end
- if not mice[name].jump then
- tfm.exec.movePlayer (name,0,0,true, 0, -60,true)
- mice[name].jump = true
- end
- end
- end
- function eventChatCommand(name,command)
- local a = {}
- for i in command:gmatch('[^%s]+') do
- table.insert(a,i)
- end
- if string.lower(a[1]) == "skip" and not mice[name].vote then
- skipVotes = skipVotes +1
- mice[name].vote = true
- elseif a[1] == "help" then
- tfm.exec.chatMessage(help,name)
- end
- if a[1] == "show" then
- local x = tonumber(a[2])
- print("id = "..squares[x].id.."<br>x = "..squares[x].x.."<br>y = "..squares[x].y)
- elseif a[1] == "me" then
- print("x = "..tfm.get.room.playerList[name].x.."<br>y = "..tfm.get.room.playerList[name].y)
- elseif a[1] == "start" and name == "Miiiclaroo" or name == "Zaxox" then
- start()
- end
- end
- function endGame()
- if not gameFinished then
- gameFinished = true
- tfm.exec.setGameTime(5)
- end
- end
- function eventLoop(t,tr)
- if tr <= 0 then
- if gameFinished then
- start()
- else
- gameFinished = true
- tfm.exec.setGameTime(5)
- end
- end
- check()
- end
- function check()
- if text <= 0 then
- text = 1
- end
- if text > 0 then
- if skipVotes >= text then
- endGame()
- end
- end
- ui.addTextArea(1002,skipVotes.." / "..text,nil,380,25,40,0,0x0010FC,0x000000,0.3,true)
- end
- main()
Advertisement
Add Comment
Please, Sign In to add comment