Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local alive = 0
- element = 1
- solido = 1
- aqualarg = 51
- aqualta = 51
- aquangle = 0
- xa = 400
- ya = 200
- earthlarg = 100
- localearth = 100
- anearth = 0
- tendi = {}
- scoressoal = {}
- scorecord = 0
- avatar = " "
- ttmp = true
- fogimp = false
- local pool = {}
- function eventTextAreaCallback(id, name, link)
- if link == "fecho" then
- ui.removeTextArea(0)
- ui.removeTextArea(-1)
- ui.removeTextArea(-2)
- elseif link == "tendi" then
- ui.removeTextArea(0)
- ui.removeTextArea(-1)
- ui.removeTextArea(-2)
- tendi[name] = true
- end
- end
- function eventMouse(name, x, y)
- if element == 4 and name == avatar then
- tfm.exec.displayParticle(26, x, y, 1, 1)
- tfm.exec.explosion(x, y, 30, 50)
- elseif element == 3 and name == avatar then
- if fogimp then
- tfm.exec.addPhysicObject(3, x, y,{type=3,width=20,height=100,miceCollision=true, groundCollision=false, friction=0.3, restitution=20, dynamic=false})
- else
- tfm.exec.addPhysicObject(3, x, y,{type=3,width=100,height=20,miceCollision=true, groundCollision=false, friction=0.3, restitution=20, dynamic=false})
- end
- elseif element == 2 and name == avatar then
- if x > localearth then
- anearth = 45
- tfm.exec.addPhysicObject(2,localearth,400,{type=6,width=200,height=earthlarg,miceCollision=true, groundCollision=true, friction=0.3, angle = anearth})
- elseif x < localearth then
- anearth = -45
- tfm.exec.addPhysicObject(2,localearth,400,{type=6,width=200,height=earthlarg,miceCollision=true, groundCollision=true, friction=0.3, angle = anearth})
- end
- elseif element == 1 and name == avatar and solido == 1 then
- if x > xa then
- aquangle = 45
- tfm.exec.addPhysicObject(1,xa,ya,{type=1,width=aqualarg,height=aqualta,miceCollision=true, groundCollision= true, foreground=false, friction=0, angle=aquangle})
- elseif x < xa then
- aquangle = -45
- tfm.exec.addPhysicObject(1,xa,ya,{type=1,width=aqualarg,height=aqualta,miceCollision=true, groundCollision= true, foreground=false, friction=0, angle=aquangle})
- end
- end
- end
- function extremos()
- if aqualarg >= 800 and element == 1 then
- aqualarg = 799
- tfm.exec.addPhysicObject(1,xa,ya,{type=9,width=aqualarg,height=aqualta,miceCollision=false, groundCollision=false, foreground=true})
- elseif aqualarg <= 50 and element == 1 then
- aqualarg = 51
- tfm.exec.addPhysicObject(1,xa,ya,{type=9,width=aqualarg,height=aqualta,miceCollision=false, groundCollision=false, foreground=true})
- end
- if aqualta >= 400 and element == 1 then
- aqualta = 399
- tfm.exec.addPhysicObject(1,xa,ya,{type=9,width=aqualarg,height=aqualta,miceCollision=false, groundCollision=false, foreground=true})
- elseif aqualta <= 50 and element == 1 then
- aqualta = 51
- tfm.exec.addPhysicObject(1,xa,ya,{type=9,width=aqualarg,height=aqualta,miceCollision=false, groundCollision=false, foreground=true})
- end
- if xa >= 800 and element == 1 and solido == 1 then
- xa = 799
- tfm.exec.addPhysicObject(1,xa,ya,{type=1,width=aqualarg,height=aqualta,miceCollision=true, groundCollision= true, foreground=false, friction=0, angle=aquangle})
- elseif xa <= 0 and element == 1 and solido == 1 then
- xa = 0
- tfm.exec.addPhysicObject(1,xa,ya,{type=1,width=aqualarg,height=aqualta,miceCollision=true, groundCollision= true, foreground=false, friction=0, angle=aquangle})
- end
- if ya <= 0 and element == 1 and solido == 1 then
- ya = 0
- tfm.exec.addPhysicObject(1,xa,ya,{type=1,width=aqualarg,height=aqualta,miceCollision=true, groundCollision= true, foreground=false, friction=0, angle=aquangle})
- elseif ya >= 400 and element == 1 and solido == 1 then
- ya = 399
- tfm.exec.addPhysicObject(1,xa,ya,{type=1,width=aqualarg,height=aqualta,miceCollision=true, groundCollision= true, foreground=false, friction=0, angle=aquangle})
- end
- if localearth >= 900 and element == 2 then
- localearth = 800
- tfm.exec.addPhysicObject(2,localearth,400,{type=6,width=200,height=earthlarg,miceCollision=true, groundCollision=true, friction=0.3, angle = anearth})
- elseif localearth <= -100 and element == 2 then
- localearth = 0
- tfm.exec.addPhysicObject(2,localearth,400,{type=6,width=200,height=earthlarg,miceCollision=true, groundCollision=true, friction=0.3, angle = anearth})
- end
- if earthlarg >= 800 and element == 2 then
- earthlarg = 799
- tfm.exec.addPhysicObject(2,localearth,400,{type=6,width=200,height=earthlarg,miceCollision=true, groundCollision=true, friction=0.3, angle = anearth})
- elseif earthlarg <= 0 and element == 2 then
- earthlarg = 0
- tfm.exec.addPhysicObject(2,localearth,400,{type=6,width=200,height=earthlarg,miceCollision=true, groundCollision=true, friction=0.3, angle = anearth})
- end
- end
- function eventKeyboard(name, key, down, x, y)
- if name == avatar then
- if key == 188 or key == 109 then
- element = element + 1
- elementos()
- elseif key == 190 or key == 107 then
- element = element - 1
- elementos()
- end
- end
- if element >= 5 and name == avatar then
- element = 1
- elementos()
- elseif element <= 0 and name == avatar then
- element = 4
- elementos()
- end
- if key == 32 and element == 1 and solido == 1 and name == avatar then
- tfm.exec.addPhysicObject(1,xa,ya,{type=9,width=aqualarg,height=aqualta,miceCollision=false, groundCollision=false, foreground=true})
- solido = 0
- elseif key == 32 and element == 1 and solido == 0 and name == avatar then
- aquangle = 0
- tfm.exec.addPhysicObject(1,xa,ya,{type=1,width=aqualarg,height=aqualta,miceCollision=true, groundCollision= true, foreground=false, friction=0, angle=aquangle})
- solido = 1
- elseif key == 32 and element == 2 and name == avatar then
- anearth = 0
- tfm.exec.addPhysicObject(2,localearth,400,{type=6,width=200,height=earthlarg,miceCollision=true, groundCollision=true, friction=0.3, angle = anearth})
- elseif key == 32 and element == 3 and name == avatar then
- if fogimp then
- tfm.exec.addPhysicObject(3, x, y,{type=3,width=20,height=100,miceCollision=true, groundCollision=false, friction=0.3, restitution=20, dynamic=false})
- else
- tfm.exec.addPhysicObject(5, x, y + 25,{type=3,width=100,height=20,miceCollision=true, groundCollision=false, friction=0.3, restitution=20, dynamic=false})
- end
- elseif key == 32 and element == 4 and name == avatar then
- tfm.exec.displayParticle(26,x,y, 1,1)
- tfm.exec.explosion(x, y, 20, 100)
- elseif key == 75 and element == 3 and name == avatar then
- tfm.exec.addPhysicObject(5, x + 20, y - 7,{type=3,width=20,height=20,miceCollision=true, groundCollision=true, friction=0.3, restitution=20, dynamic=true, fixedRotation=1})
- table.insert(pool, {tfm.exec.addShamanObject(6000, x + 1, y - 7,0, 1, 0, true), os.time()})
- elseif key == 72 and element == 3 and name == avatar then
- tfm.exec.addPhysicObject(5, x - 20, y - 7,{type=3,width=20,height=20,miceCollision=true, groundCollision=true, friction=0.3, restitution=20, dynamic=true, fixedRotation=1})
- table.insert(pool, {tfm.exec.addShamanObject(6000, x - 1, y - 7,0, -1, 0, true), os.time()})
- elseif key == 74 and element == 3 and name == avatar then
- fogimp = false
- elseif key == 85 and element == 3 and name == avatar then
- fogimp = true
- elseif key == 75 and element == 1 and solido == 0 and name == avatar then
- aqualarg = aqualarg + 20
- aqualta = 50
- tfm.exec.addPhysicObject(1,xa,ya,{type=9,width=aqualarg,height=aqualta,miceCollision=false, groundCollision=false, foreground=true})
- extremos()
- elseif key == 75 and element == 1 and solido == 1 and name == avatar then
- xa = xa + 100
- tfm.exec.addPhysicObject(1,xa,ya,{type=1,width=aqualarg,height=aqualta,miceCollision=true, groundCollision= true, foreground=false, friction=0, angle=aquangle})
- extremos()
- elseif key == 72 and element == 1 and solido == 1 and name == avatar then
- xa = xa -100
- tfm.exec.addPhysicObject(1,xa,ya,{type=1,width=aqualarg,height=aqualta,miceCollision=true, groundCollision= true, foreground=false, friction=0, angle=aquangle})
- extremos()
- elseif key == 72 and element == 1 and solido == 0 and name == avatar then
- aqualarg = aqualarg - 20
- aqualta = 50
- tfm.exec.addPhysicObject(1,xa,ya,{type=9,width=aqualarg,height=aqualta,miceCollision=false, groundCollision=false, foreground=true})
- extremos()
- elseif key == 74 and element == 1 and solido == 0 and name == avatar then
- aqualta = aqualta - 20
- aqualarg = 50
- tfm.exec.addPhysicObject(1,xa,ya,{type=9,width=aqualarg,height=aqualta,miceCollision=false, groundCollision=false, foreground=true})
- extremos()
- elseif key == 74 and element == 1 and solido == 1 and name == avatar then
- ya = ya + 50
- tfm.exec.addPhysicObject(1,xa,ya,{type=1,width=aqualarg,height=aqualta,miceCollision=true, groundCollision= true, foreground=false, friction=0, angle=aquangle})
- extremos()
- elseif key == 85 and element == 1 and solido == 0 and name == avatar then
- aqualta = aqualta + 20
- aqualarg = 50
- tfm.exec.addPhysicObject(1,xa,ya,{type=9,width=aqualarg,height=aqualta,miceCollision=false, groundCollision=false, foreground=true})
- extremos()
- elseif key == 85 and element == 1 and solido == 1 and name == avatar then
- ya = ya - 50
- tfm.exec.addPhysicObject(1,xa,ya,{type=1,width=aqualarg,height=aqualta,miceCollision=true, groundCollision= true, foreground=false, friction=0, angle=aquangle})
- extremos()
- elseif key == 75 and element == 2 and name == avatar then
- localearth = localearth + 200
- tfm.exec.addPhysicObject(2,localearth,400,{type=6,width=200,height=earthlarg,miceCollision=true, groundCollision=true, friction=0.3, angle = anearth})
- extremos()
- elseif key == 75 and element == 4 and name == avatar then
- tfm.exec.displayParticle(27,x,y, 1,1)
- tfm.exec.movePlayer(name,0,0,true,40,0,true)
- elseif key == 72 and element == 2 and name == avatar then
- localearth = localearth - 200
- tfm.exec.addPhysicObject(2,localearth,400,{type=6,width=200,height=earthlarg,miceCollision=true, groundCollision=true, friction=0.3, angle = anearth})
- extremos()
- elseif key == 72 and element == 4 and name == avatar then
- tfm.exec.displayParticle(27,x,y, 1,1)
- tfm.exec.movePlayer(name,0,0,true,-40,0,true)
- elseif key == 85 and element == 2 and name == avatar then
- earthlarg = earthlarg + 50
- tfm.exec.addPhysicObject(2,localearth,400,{type=6,width=200,height=earthlarg,miceCollision=true, groundCollision=true, friction=0.3, angle = anearth})
- extremos()
- elseif key == 85 and element == 4 and name == avatar then
- tfm.exec.displayParticle(27,x,y, 1,1)
- tfm.exec.movePlayer(name,0,0,true,0,-40,true)
- elseif key == 74 and element == 2 and name == avatar then
- earthlarg = earthlarg - 50
- tfm.exec.addPhysicObject(2,localearth,400,{type=6,width=200,height=earthlarg,miceCollision=true, groundCollision=true, friction=0.3, angle = anearth})
- extremos()
- end
- end
- function eventLoop(ct, tr)
- if alive <= 0 then
- alive = 0
- end
- if tr <= 0 then
- initial()
- elseif tr <= 10 then
- ttmp = false
- end
- for i,v in ipairs(pool) do
- if v[2] < os.time() - 1000 then
- tfm.exec.removeObject(v[1])
- table.remove(pool, i)
- end
- end
- for name in pairs(tfm.get.room.playerList) do
- if scoressoal[name] > scorecord then
- scorecord = scoressoal[name]
- end
- end
- end
- for name in pairs(tfm.get.room.playerList) do
- scoressoal[name] = 0
- tendi[name] = false
- tfm.exec.setPlayerScore(name, 0, false)
- if name == avatar then
- tfm.exec.changePlayerSize(avatar, 1.2)
- tfm.exec.setPlayerScore(avatar, 0)
- ui.setMapName("avatartar e a lenda de "..avatar.."")
- if tendi[name] == false then
- ui.addTextArea(-2, "<a href=\"event:tendi\"><r>Não mostrar novamente!", avatar, 330, 155, xua, yua, 0x17262e, 0x000000, 1, true)
- ui.addTextArea(-1, "<a href=\"event:fecho\"><r>Ok, entendi!", avatar, 365, 255, xua, yua, 0x17262e, 0x000000, 1, true)
- ui.addTextArea(0, "Você é o avatar e deve dominar os elementos para\najudar os ratos a pegarem o queijo! Aperte os \nbotões <r>, <n>e <r>. <n>para trocar o elemento, aperte <r>espaço\n<n>para dominar e as letras <r>U H J K<n> ou o <r>clique do \nmouse<n>, para mexer em algumas especificações.", avatar, 250, 180, xua, yua, 0x17262e, 0x000000, 1, true)
- end
- end
- for id = 0,255 do
- system.bindKeyboard(name,id,true,true)
- system.bindMouse(name, true)
- end
- end
- function eventNewPlayer(name)
- scoressoal[name] = 0
- tendi[name] = false
- for id = 0,255 do
- system.bindKeyboard(name,id,true,true)
- system.bindMouse(name, true)
- end
- end
- function eventPlayerDied(name)
- local morto=0
- local n
- for pname,player in pairs(tfm.get.room.playerList) do
- if not player.isDead then
- morto=morto+1
- n=pname
- end
- end
- if name == avatar then
- tfm.exec.setPlayerScore(avatar, 0, false)
- if ttmp then
- tfm.exec.setGameTime(10)
- ttmp = false
- end
- else
- tfm.exec.setPlayerScore(name, 1, true)
- scoressoal[name] = scoressoal[name] + 1
- end
- if morto == 0 then
- initial()
- end
- end
- function eventPlayerWon(name)
- local vitoria = 0
- local n
- for pname,player in pairs(tfm.get.room.playerList) do
- if not player.Win then
- vitoria = vitoria + 1
- n=pname
- end
- end
- if name == avatar then
- tfm.exec.setPlayerScore(name, 0, false)
- if ttmp then
- tfm.exec.setGameTime(10)
- ttmp = false
- end
- else
- tfm.exec.setPlayerScore(name, 10, true)
- scoressoal[name] = scoressoal[name] + 10
- end
- if vitoria <= 0 then
- initial()
- end
- end
- function elementos()
- for name in pairs(tfm.get.room.playerList) do
- if element == 1 then
- tfm.exec.setNameColor(avatar, 0x00D0FF)
- ui.setMapName("Avatar: a lenda de <font color=\"#00D0FF\">"..avatar.."")
- ui.addTextArea(1, "<b><p align='center'><font size='13' color='#000000'>Agua</font></p></b>", avatar, 5,375,100,20, 0x00D0FF, 0, 1, true)
- elseif element == 2 then
- tfm.exec.setNameColor(avatar, 0x300005)
- ui.setMapName("Avatar: a lenda de <font color=\"#300005\">"..avatar.."")
- ui.addTextArea(1, "<b><p align='center'><font size='13' color='#000000'>Terra</font></p></b>", avatar, 5,375,100,20, 0x300005, 0, 1, true)
- elseif element == 3 then
- tfm.exec.setNameColor(avatar, 0xC72535)
- ui.setMapName("Avatar: a lenda de <font color=\"#C72535\">"..avatar.."")
- ui.addTextArea(1, "<b><p align='center'><font size='13' color='#000000'>Fogo</font></p></b>", avatar, 5,375,100,20, 0xC72535, 0, 1, true)
- elseif element == 4 then
- tfm.exec.setNameColor(avatar, 0xC8C5C5)
- ui.setMapName("Avatar: a lenda de <font color=\"#C8C5C5\">"..avatar.."")
- ui.addTextArea(1, "<b><p align='center'><font size='13' color='#000000'>Ar</font></p></b>", avatar, 5,375,100,20, 0xC8C5C5, 0, 1, true)
- end
- end
- end
- function sha()
- local p = {}
- for k, v in next, tfm.get.room.playerList do
- for name in pairs(tfm.get.room.playerList) do
- if scoressoal[name] == scorecord then
- p[#p + 1] = k
- if name == avatar then
- scorecord = 0
- scoressoal[avatar] = 0
- tfm.exec.setPlayerScore(avatar, 0, false)
- end
- end
- end
- end
- return p[math.random(#p)]
- end
- function initial()
- local dia = {"#4","#8"}
- tfm.exec.disableAutoShaman(true)
- tfm.exec.disableAutoScore()
- tfm.exec.newGame(dia[math.random(#dia)])
- avatar = sha()
- for name in pairs(tfm.get.room.playerList) do
- if name == avatar then
- tfm.exec.changePlayerSize(avatar, 1.2)
- tfm.exec.setPlayerScore(avatar, 0)
- elementos()
- if tendi[name] == false then
- ui.addTextArea(-2, "<a href=\"event:tendi\"><r>Não mostrar novamente!", avatar, 330, 155, xua, yua, 0x17262e, 0x000000, 1, true)
- ui.addTextArea(-1, "<a href=\"event:fecho\"><r>Ok, entendi!", avatar, 365, 255, xua, yua, 0x17262e, 0x000000, 1, true)
- ui.addTextArea(0, "Você é o avatar e deve dominar os elementos para\najudar os ratos a pegarem o queijo! Aperte os \nbotões <r>, <n>e <r>. <n>para trocar o elemento, aperte <r>espaço\n<n>para dominar e as letras <r>U H J K<n> ou o <r>clique do \nmouse<n>, para mexer em algumas especificações.", avatar, 250, 180, xua, yua, 0x17262e, 0x000000, 1, true)
- end
- end
- end
- end
- initial()
- function eventNewGame()
- ttmp = true
- p = {}
- aqualarg = 100
- xa = 400
- ya = 200
- earthlarg = 100
- localearth = 100
- for name in pairs(tfm.get.room.playerList) do
- tfm.exec.setPlayerScore(avatar, 0, false)
- tfm.exec.changePlayerSize(name, 1)
- for id =-2,4 do
- ui.removeTextArea(id, name)
- end
- end
- initial()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement