Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- adm="Jellymichey#0000"
- lang="PT"
- blockRespawnRate=5
- chatMessages=true
- -----------------------------------------------------------------------
- recreatingBlocks={}
- recreatingBlocksNumber=0
- arrayUIs={}
- textareas={}
- definition={{name="type",type="integer"},{name="friction",type="integer"},{name="restitution",type="integer"},{name="color",type="color"},{name="foreground",type="boolean"},{name="miceCollision",type="boolean"},{name="width",type="integer"},{name="height",type="integer"},{name="angle",type="integer"}}
- function distance ( x1, y1, x2, y2 )
- local dx = x1 - x2
- local dy = y1 - y2
- return math.sqrt ( dx * dx + dy * dy )
- end
- function unload()
- print("unloading")
- --eventLoop=system.exit()
- end
- function absoluteMiceCollision(b)
- if b==nil then return nil end
- if b.miceCollision==nil then
- return true
- end
- return b.miceCollision
- end
- function table.clone(orig)
- local orig_type = type(orig)
- local copy
- if orig_type == 'table' then
- copy = {}
- for orig_key, orig_value in next, orig, nil do
- copy[table.clone(orig_key)] = table.clone(orig_value)
- end
- setmetatable(copy, table.clone(getmetatable(orig)))
- else -- number, string, boolean, etc
- copy = orig
- end
- return copy
- end
- function initAdminData()
- return {type=0,timeSinceTyped=os.time(),isTeleporting=false,customnized=table.clone(prop[12]),callingValue="",showingCustom=false}
- end
- function table.slice(tbl, first, last, step)
- local sliced = {}
- for i = first or 1, last or #tbl, step or 1 do
- sliced[#sliced+1] = tbl[i]
- end
- return sliced
- end
- function tablelength(T)
- local count = 0
- for _ in pairs(T) do count = count + 1 end
- return count
- end
- function generateCrambledText()
- local abc = "abcdefghijklmnopqrstuvwxyz"
- local ret = ""
- for i=1,20 do
- local e=math.random(1,string.len(abc))
- ret=ret..string.sub(abc,e,e)
- end
- return ret
- end
- do
- local cm=tfm.exec.chatMessage
- tfm.exec.chatMessage=function(c,n) print("("..tostring(n)..") "..c) cm(c,n) end
- end
- spawnpointPlayers={}
- blocksInUse=0
- translation={PT={
- settings_MAP3="4 paredes",
- settings_MAP2="com paredes",
- settings_MAP1="normal",
- settings_MAP="estilo de mapa",
- settings_GRAVITY="gravidade",
- settings_WIND="vento",
- settings_WIDTH="largura do mapa",
- settings_HEIGHT="altura do mapa",
- settings_START="começar/carregar o mapa",
- settings_USTART="temos que esperar 3s para carregar o mapa",
- settings_popup_GRAVITY="gravidade",
- settings_popup_WIND="vento",
- settings_popup_WIDTH="largura",
- settings_popup_HEIGHT="altura",
- mapLoader="Carregando o mapa para você! :)",
- custom_type="Tipo do bloco (do tfm)",
- custom_friction="fricção",
- custom_restitution="restituição",
- custom_color="cor",
- custom_miceCollision="colisão com rato",
- custom_width="largura",
- custom_height="altura",
- custom_angle="angulo",
- custom_foreground="primeiro plano",
- custom_import="importar bloco selecionado",
- custom_import_ERROR="você não pode importar o bloco ",
- adm_ERROR_supremeDowngrade="Tentar diminuir o supremo não é possível. flw",
- adm_ERROR_autoDowngrade="Tentar diminuir você mesmo não é muito bom...",
- start_message="cuidado com o",
- help_ENVMAKE="aqui você pode clicar em tudo quanto é mapa para criar bloco! Você pode estacar blocos se a colisão deles for diferente! Para mudar de bloco você pode escrever !0 até !18 ou nas emoções!",
- help_MAPCONFIG="aqui você tem que configurar o mapa antes de ir jogar com ela!",
- settings_CHEESE="precisa de queijo",
- map_spawn_kill="Você perdeu o spawnoint! Vá se salvar em outro!"
- },
- EN={
- settings_CHEESE="requires cheese",
- settings_MAP3="4 walls",
- settings_MAP2="with walls",
- settings_MAP1="normal",
- settings_MAP="map style",
- settings_GRAVITY="gravity",
- settings_WIND="wind",
- settings_WIDTH="map width",
- settings_HEIGHT="map height",
- settings_START="load map/start",
- settings_USTART="We need to wait 3s to load map",
- settings_popup_GRAVITY="gravity",
- settings_popup_WIND="wind",
- settings_popup_WIDTH="width",
- settings_popup_HEIGHT="height",
- mapLoader="game is loading tiles for you :)",
- custom_type="(from tfm) block type",
- custom_friction="friction",
- custom_restitution="restitution",
- custom_color="color",
- custom_miceCollision="collision with mice",
- custom_width="width",
- custom_height="height",
- custom_angle="angle",
- custom_foreground="foreground",
- custom_import="import selected block",
- custom_import_ERROR="you can't import ",
- adm_ERROR_supremeDowngrade="Trying to downgrade the supreme isn't possible. Bye",
- adm_ERROR_autoDowngrade="Downgrading yourself isn't very good...",
- start_message="beware of",
- help_ENVMAKE="here you can click on everything you want to to create blocks! You can also stack up blocos with different collision setting! To change the block you can type !0 to !18 or on the emotions!",
- help_MAPCONFIG="here you need to config everything before playing with it!",
- map_spawn_kill="You lost spawnpoint! Go find a new one!"
- }}
- function getWord(language,thing)
- if translation[lang] then
- if translation[lang][thing] then
- return translation[lang][thing]
- else
- return thing
- end
- else
- if translation.EN[thing] then
- return translation.EN[thing]
- else
- return thing
- end
- end
- end
- tfm.exec.disableAutoNewGame(true)
- tfm.exec.disableAutoShaman(true)
- tfm.exec.disableAfkDeath(true)
- tfm.exec.disablePhysicalConsumables (true)
- widesness=800
- cheeseRequired=false
- spection={}
- playersEntered={}
- admins={}
- playerData={}
- mapPred="normal"
- gravityFactor={gravity=10,wind=0}
- heightness=400
- showCustom=false
- spawnpointTiles={}
- CstDefs={type=0,width=40,height=40,friction=0.3,restitution=0.2,color=0xaaaaaa}
- DefCall=""
- prop = {}
- prop[0] = {type=0,width=40,height=40,friction=0.3,restitution=0.2}
- prop[1] = {type=1,width=40,height=40,friction=0,restitution=0.2}
- prop[2] = {type=2,width=40,height=40,friction=0,restitution=1.2}
- prop[3] = {type=3,width=40,height=40,friction=0,restitution=20}
- prop[4] = {type=4,width=40,height=40,friction=20,restitution=0.2}
- prop[5] = {type=5,width=40,height=40,friction=0.3,restitution=0.2}
- prop[6] = {type=6,width=40,height=40,friction=0.3,restitution=0.2}
- prop[7] = {type=7,width=40,height=40,friction=0.1,restitution=0.2}
- prop[8] = {type=8,width=40,height=40,friction=0.3,restitution=0.2,miceCollision=false}
- prop[9] = {type=9,width=40,height=40,friction=0.3,restitution=0.2,miceCollision=false}
- prop[10] = {type=10,width=40,height=40,friction=0.3,restitution=0}
- prop[11] = {type=11,width=40,height=40,friction=0.05,restitution=0.1}
- prop[12] = {type=12,width=40,height=40,friction=0.3,restitution=0.2,color=0xaaaaaa}
- prop[13] = {type=13,width=20,friction=0.3,restitution=0.2,color=0xaaaaaa}
- prop[14] = {type=14,width=40,height=40,friction=0.3,restitution=0.2,color=0xaaaaaa}
- prop[15] = {type=15,width=40,height=40,friction=0.3,restitution=0.2,color=0xaaaaaa,miceCollision=false}
- prop[16] = {type=4,width=10,height=40,friction=20,restitution=0.2,color=0xaaaaaa}
- prop[17] = {type=0,width=10,height=40,friction=0.3,restitution=0.2,color=0xaaaaaa}
- prop[18] = {type=1,width=10,height=10,friction=0,restitution=0.2,color=0xaaaaaa,angle=45}
- function makeMapMaker(fromMain)
- if fromMain==nil then
- tiles={}
- start="nil"
- finish="nil"
- ui.removeTextArea(0)
- ui.removeTextArea(1)
- for x,v in pairs(spawnpointTiles) do
- ui.removeTextArea(v.ui)
- end
- for x,v in pairs(textareas) do
- ui.removeTextArea(v.textarea)
- end
- textareas={}
- for _,x in pairs(playerData) do
- x.spawnpointPlayers.place="nil"
- end
- spawnpointTiles = {}
- end
- tfm.exec.chatMessage(getWord(lang,"help_MAPCONFIG"),adm)
- blocksInUse=0
- tfm.exec.newGame('<C><P /><Z><S /><D /><O /></Z></C>')
- isOnMenu=true
- ui.addTextArea(2, '<p align=\"right\"><a href="event:wide">'..getWord(lang,"settings_WIDTH")..'</a></p>', adm, 0, 20, 400, 0, 0x123450, 0x123450, 1, false)
- ui.addTextArea(3, "<a href=\"event:height\">"..getWord(lang,"settings_HEIGHT").."</a>", adm, 400, 20, 400, 0, 0x123450, 0x123450, 1, false)
- ui.addTextArea(4, "<p align=\"center\">"..getWord(lang,"settings_USTART").."</p>", adm, 0, 60, 800, 0, 0x123450, 0x123450, 1, false)
- ui.addTextArea(5, '<p align="right"><a href=\"event:gravity\">'..getWord(lang,"settings_GRAVITY")..'</a></p>', adm, 0, 40, 400, 0, 0x123450, 0x123450, 1, false)
- ui.addTextArea(6, '<a href="event:wind">'..getWord(lang,"settings_WIND")..'</a>', adm, 400, 40, 400, 0, 0x123450, 0x123450, 1, false)
- ui.addTextArea(7, "<font color=\"#"..(cheeseRequired and "00ff00" or "ff0000").."\">".."<a href=\"event:requiredCheese\">"..getWord(lang,"settings_CHEESE").."</a>", adm, 00, 360, 800, 0, 0x123450, 0x123450, 1, false)
- ui.addTextArea(8, getWord(lang,"settings_MAP")..': <a href="event:map1">'..getWord(lang,"settings_MAP1")..'</a>, <a href="event:map2">'..getWord(lang,"settings_MAP2")..'</a>, <a href="event:map3">'..getWord(lang,"settings_MAP3")..'</a>', adm, 0, 380, 800, 0, 0x123450, 0x123450, 1, false)
- end
- if tfm.get.room.playerList[adm]==nil then ---------------
- scrambledText=generateCrambledText()
- print(scrambledText)
- ui.addTextArea(1, 'who\'ll write '..scrambledText.." wins admin...", nil, 0, 250, 400, 0, 0x123450, 0x123450, 1, true)
- flyPerm={}
- else
- flyPerm={adm}
- admins={[adm]=initAdminData()}
- ui.addTextArea(1, getWord(lang,"start_message")..' '..adm.."...", nil, 0, 250, 400, 0, 0x123450, 0x123450, 1, false)
- ui.addTextArea(1, '!number -> select block<br>!start -> starting point<br>!finish -> ending point<br>!spawnpoint -> creates spawnpoint<br>!fly player#0000 ->set a player to fly<br>!reset -> resets map', adm, 0, 250, 400, 0, 0x123450, 0x123450, 1, false)
- makeMapMaker(true)
- end
- function eventNewGame()
- lastId="nil"
- ui.setShamanName (adm)
- ui.setMapName(adm.." <BL>- @-1")
- for i,v in pairs(tfm.get.room.playerList) do
- tfm.exec.killPlayer(i)
- end
- end
- function eventTextAreaCallback( id, j, c)
- local sucess,status=pcall(function( id, j, c)
- print("")
- local cl={}
- for i in string.gmatch(c,"[^;]+") do
- cl[#cl+1]=i
- end
- if c=="wide" then
- ui.addPopup(0, 2, getWord(lang,"settings_popup_WIDTH"), adm, 300, 150, 200, true)
- elseif c=="requiredCheese" then
- cheeseRequired=not cheeseRequired
- ui.updateTextArea(7,"<font color=\"#"..(cheeseRequired and "00ff00" or "ff0000").."\">".."<a href=\"event:requiredCheese\">"..getWord(lang,"settings_CHEESE").."</a>")
- elseif c == "height" then
- ui.addPopup(1, 2, getWord(lang,"settings_popup_HEIGHT"), adm, 300, 150, 200, true)
- elseif c == "start" then
- isOnMenu=false
- tfm.exec.chatMessage(getWord(lang,"help_ENVMAKE"),adm)
- tfm.exec.newGame('<C><P G="'..gravityFactor["wind"]..','..gravityFactor["gravity"]..'" H="'..heightness..'" L="'..widesness..'"/><Z><S /><D /><O /></Z></C>')
- for i=1,8 do
- ui.removeTextArea(i,nil)
- end
- mapCreator=coroutine.create(function() local fc = 0
- if mapPred=="walls" or mapPred=="4w" then
- for i=0,tonumber(heightness/40) do
- compBlocks(0,i*40,1)
- fc=fc+1
- if fc==3 then coroutine.yield() fc=0 end
- end
- for i=0,tonumber(heightness/40) do
- compBlocks(widesness-1,i*40,1)
- fc=fc+1
- if fc==3 then coroutine.yield() fc=0 end
- end
- end
- if mapPred=="4w" then
- for i=0,tonumber((widesness-1)/40) do
- compBlocks(i*40,0,1)
- fc=fc+1
- if fc==3 then coroutine.yield() fc=0 end
- end
- for i=0,tonumber((widesness-1)/40) do
- compBlocks(i*40,heightness-1,1)
- fc=fc+1
- if fc==3 then coroutine.yield() fc=0 end
- end
- end end)
- elseif c == "import" then
- if tonumber(admins[j].type)==nil then
- tfm.exec.chatMessage("<R>".. getWord(lang,"custom_import_ERROR") .. admins[j].type .."!",j)
- else
- admins[j].customnized=table.clone(prop[admins[j].type])
- end
- elseif c=="map1" then
- mapPred="normal"
- elseif c=="map2" then
- mapPred="walls"
- elseif c=="map3" then
- mapPred="4w"
- elseif c=="gravity" then
- ui.addPopup(3, 2, getWord(lang,"settings_popup_GRAVITY"), adm, 300, 150, 200, true)
- elseif c=="wind" then
- ui.addPopup(4, 2, getWord(lang,"settings_popup_WIND"), adm, 300, 150, 200, true)
- elseif cl[1]=="valueChange" then
- admins[j].callingValue=cl[2]
- if cl[3]=="integer" then
- ui.addPopup(2, 2, cl[2] .. " set value", j, 300, 150, 200, true)
- ui.addPopup(5, 1, cl[2] .. " set value", j, 300, 420, 200, true)
- elseif cl[3]=="color" then
- ui.showColorPicker (0, j, 0x000000, cl[2] .. " set value")
- ui.addPopup(2, 2, cl[2] .. " set value", j, 300, 420, 200, true)
- ui.addPopup(5, 1, cl[2] .. " set value", j, 300, 420, 200, true)
- elseif cl[3]=="boolean" then
- ui.addPopup(5, 1, cl[2] .. " set value", j, 300, 150, 200, true)
- ui.addPopup(2, 2, cl[2] .. " set value", j, 300, 420, 420, true)
- end
- end
- end,id,j,c)
- if not(sucess) then tfm.exec.chatMessage("editor crashou... Envie o motivo do crash ao Jellymichey#0000<br>"..status) unload() end
- end
- tiles={}
- start="nil"
- finish="nil"
- function eventKeyboard(j,c,p,x,y)
- local sucess,status=pcall(function(j,c,p,x,y)
- if c==32 then
- for _,i in pairs(flyPerm) do
- if j==i then
- tfm.exec.movePlayer(j, 0, 0, true, 0, -50, true)
- tfm.exec.displayParticle (13, x, y, 0, 0, 0, 0)
- end
- end
- end
- if c>=48 and c<=57 and admins[j] then
- if admins[j].timeSinceTyped>os.time()-1000 then
- if string.len(tostring(admins[j].type))~=2 then
- admins[j].type=tonumber(admins[j].type..tostring(c-48))
- end
- else
- admins[j].type=c-48
- end
- admins[j].timeSinceTyped=os.time()
- if admins[j].type>#prop then
- admins[j].type=#prop
- end
- ui.addTextArea (-1, tostring(admins[j].type), j, 0, 370, 20, 20, 0x111111, 0x111111, 1, true)
- end
- if c==40 or c==83 then
- for id,n in pairs(spawnpointTiles) do
- if x < n["x"]+20 and x > n["x"]-10 and y < n["y"]+20 and y > n["y"]-10 and (not tfm.get.room.playerList[j].isDead) then
- playerData[j].spawnpointPlayers.place={}
- playerData[j].spawnpointPlayers.place[1]=x
- playerData[j].spawnpointPlayers.place[2]=y
- if playerData[j].spawnpointPlayers.spawnId~="nil" then
- spawnpointTiles[playerData[j].spawnpointPlayers.spawnId].peopleUsing[j]=nil
- end
- playerData[j].spawnpointPlayers.spawnId=id
- n.peopleUsing[j]=true
- playerData[j].spawnpointPlayers.cheese=tfm.get.room.playerList[j].hasCheese
- for xx=-60,0 do
- tfm.exec.displayParticle (0, x, y+(xx*5), 0, 0, math.random(-10,10)/100, 0, j)
- end
- end
- end
- end
- end,j,c,p,x,y)
- if not(sucess) then tfm.exec.chatMessage("editor crashou... Envie o motivo do crash ao Jellymichey#0000<br>"..status) unload() end
- end
- function eventNewPlayer(n)
- local sucess,status=pcall(function(n)
- tfm.exec.chatMessage("<J>humm bom dia! #editor feito pelo Jellymichey#0000!<br>neste module os admins fazem o mapa e vocês, ratinhos, tentam resolê-lo</J>",n)
- playerData[n]={}
- if not isOnMenu then
- recreator=coroutine.create(function()
- while tablelength(recreatingBlocks)~=0 do
- for i=0,blockRespawnRate do
- tfm.exec.removePhysicObject(#recreatingBlocks)
- tfm.exec.addPhysicObject(#recreatingBlocks, recreatingBlocks[#recreatingBlocks]["x"], recreatingBlocks[#recreatingBlocks]["y"], recreatingBlocks[#recreatingBlocks]["defs"])
- recreatingBlocks[#recreatingBlocks]=nil
- if tablelength(recreatingBlocks)==0 then break end
- end
- coroutine.yield()
- end
- end)
- recreatingBlocks=table.clone(tiles)
- recreatingBlocksNumber=tablelength(recreatingBlocks)
- ui.addTextArea(-3, "<p align=\"center\"><font size=\"20\">"..getWord(lang,"mapLoader").."</font></p>", n, 0, 20, 800, 400, 0x111111, 0x111111, 0.7, true)
- end
- playerData[n].spawnpointPlayers={place="nil",cheese=false,spawnId="nil"}
- system.bindKeyboard(n, 32, false, true)
- for i=48,57 do
- system.bindKeyboard(n, i, false, true)
- end
- system.bindKeyboard(n, 40, false, true)
- system.bindKeyboard(n, 83, false, true)
- system.bindMouse(n,true)
- playersEntered[#playersEntered+1]=n
- end,n)
- if not(sucess) then tfm.exec.chatMessage("editor crashou... Envie o motivo do crash ao Jellymichey#0000<br>"..status) unload() end
- end
- function eventPlayerDied(n)
- if not(start=="nil") then
- if spection[n] then return end
- tfm.exec.respawnPlayer(n)
- end
- end
- function eventPlayerRespawn(n)
- local sucess,status=pcall(function(n)
- if not(isOnMenu) then
- if playerData[n].spawnpointPlayers.place=="nil" then
- if start~="nil" then
- print("a")
- tfm.exec.movePlayer(n, start[1]+25, start[2]+25, false, 0, 0, false)
- end
- else
- tfm.exec.movePlayer(n, playerData[n].spawnpointPlayers.place[1], playerData[n].spawnpointPlayers.place[2], false, 0, 0, false)
- if playerData[n].spawnpointPlayers.cheese then
- tfm.exec.giveCheese(n)
- end
- end
- if adm==n then
- tfm.exec.setNameColor ( n, 0xffff00)
- end
- for _,i in pairs(admins) do
- tfm.exec.setNameColor (i, 0x00ff00)
- end
- end
- end,n)
- if not(sucess) then tfm.exec.chatMessage("editor crashou... Envie o motivo do crash ao Jellymichey#0000<br>"..status) unload() end
- end
- function eventPlayerWon(n)
- playerData[n].spawnpointPlayers.place="nil"
- eventPlayerDied(n)
- end
- function compBlocks(x,y,thisType,customed)
- if (tonumber(thisType)==nil) then
- if thisType == "start" then
- ui.addTextArea (0, "", nil, math.floor(x/40)*40+15, math.floor(y/40)*40+15, 25, 25, 0xff0000, 0xff0000, 1, false)
- start={math.floor(x/40)*40,math.floor(y/40)*40}
- for i in pairs(tfm.get.room.playerList) do
- eventPlayerDied(i)
- end
- end
- if thisType == "finish" then
- ui.addTextArea (1, "", nil, math.floor(x/40)*40+15, math.floor(y/40)*40+15, 25, 25, 0x00ff00, 0x00ff00, 1, false)
- finish={(math.floor(x/40)*40),(math.floor(y/40)*40)}
- end
- if thisType == "spawnpoint" then
- local have = false
- local id = ""
- for v,n in pairs(spawnpointTiles) do
- if n["x"] == math.floor(x/40)*40+25 and n["y"] == math.floor(y/40)*40+25 then
- have=true
- id=v
- end
- end
- if have==true then
- ui.removeTextArea(spawnpointTiles[id].ui,nil)
- for i in pairs(spawnpointTiles[id].peopleUsing) do
- tfm.exec.chatMessage("<V>"..getWord(lang,"map_spawn_kill"),i)
- playerData[i].spawnpointPlayers={place="nil",cheese=false,spawnId="nil"}
- end
- spawnpointTiles[id]=nil
- else
- local i = 1
- while not(spawnpointTiles[i]==nil) do
- i=i+1
- end
- local ii = 10
- while not(arrayUIs[ii]==nil) do
- ii = ii + 1
- end
- arrayUIs[ii]="spawnpoint"
- spawnpointTiles[i]={peopleUsing={},ui=ii,x=math.floor(x/40)*40+25,y=math.floor(y/40)*40+25}
- ui.addTextArea (ii, "", nil, math.floor(x/40)*40+15, math.floor(y/40)*40+15, 25, 25, 0xffff00, 0xffff00, 1, false)
- end
- end
- if thisType == "custom" then
- local have = false
- local id = ""
- for v,n in pairs(tiles) do
- if n["x"] == math.floor(x/40)*40+25 and n["y"] == math.floor(y/40)*40+25 and absoluteMiceCollision(n.defs)==absoluteMiceCollision(customed) then
- have = true
- id=v
- end
- end
- if have==true then
- tfm.exec.removePhysicObject(id)
- blocksInUse=blocksInUse-1
- tiles[id]=nil
- else
- local i = 1
- while not(tiles[i]==nil) do
- i=i+1
- end
- if blocksInUse<480 then
- tfm.exec.addPhysicObject(i, math.floor(x/40)*40+25, math.floor(y/40)*40+25, table.clone(customed))
- tiles[i]={x=math.floor(x/40)*40+25,y=math.floor(y/40)*40+25,defs=table.clone(customed)}
- blocksInUse=blocksInUse+1
- lastId=i
- end
- end
- end
- else
- local have = false
- local id = ""
- for v,n in pairs(tiles) do
- if n["x"] == math.floor(x/40)*40+25 and n["y"] == math.floor(y/40)*40+25 and absoluteMiceCollision(n.defs)==absoluteMiceCollision(prop[thisType]) then
- have = true
- id=v
- end
- end
- if have==true then
- tfm.exec.removePhysicObject(id)
- blocksInUse=blocksInUse-1
- tiles[id]=nil
- else
- local i = 1
- while not(tiles[i]==nil) do
- i=i+1
- end
- if blocksInUse<480 then
- tfm.exec.addPhysicObject(i, math.floor(x/40)*40+25, math.floor(y/40)*40+25, prop[thisType])
- tiles[i]={x=math.floor(x/40)*40+25,y=math.floor(y/40)*40+25,defs=prop[thisType]}
- blocksInUse=blocksInUse+1
- lastId=i
- end
- end
- ui.addTextArea(-2,blocksInUse.."/480 blocks",nil,700,380,100,20,0x111111,0x111111,1,true)
- end
- end
- function eventMouse(n,x,y,remoteBlock)
- local sucess,status=pcall(function(n,x,y,remoteBlock)
- print(admins[n])
- if not(isOnMenu) and admins[n] then
- thisType=admins[n].type
- if not(remoteBlock==nil) then
- thisType=remoteBlock
- end
- if admins[n].panflet then
- if admins[n].panflet=="" then
- local d=""
- for i,v in pairs(textareas) do
- if distance(x,y,v.x,v.y)<30 then
- arrayUIs[v.textarea]=nil
- ui.removeTextArea(v.textarea)
- d=i
- break
- end
- end
- if d~="" then
- textareas[d]=nil
- end
- admins[n].panflet=nil
- return
- else
- local i = 0
- while not(textareas[i]==nil) do
- i = i + 1
- end
- local ii = 10
- while not(arrayUIs[ii]==nil) do
- ii = ii + 1
- end
- arrayUIs[ii]="textarea"
- textareas[i]={textarea=ii,text=admins[n].panflet,x=x,y=y}
- ui.addTextArea(ii, admins[n].panflet, nil, x, y, 0, 0, 0x111111, 0x111111, 1, false)
- admins[n].panflet=nil
- return
- end
- end
- if admins[n].isTeleporting~=false then
- tfm.exec.movePlayer(admins[n].isTeleporting,x,y,false,0,0,true)
- admins[n].isTeleporting=false
- else
- compBlocks(x,y,thisType,admins[n].customnized)
- end
- end
- end,n,x,y,remoteBlock)
- if not(sucess) then tfm.exec.chatMessage("editor crashou... Envie o motivo do crash ao Jellymichey#0000<br>"..status) unload() end
- end
- function eventChatCommand(n,c)
- local sucess,status=pcall(function(n,c)
- local rules = {}
- for i in string.gmatch(c,"[^ ]+") do
- rules[#rules+1]=i
- end
- if admins[n] then
- if tonumber(c) == nil and c ~= "use" and rules[1]~="t" then
- for _,i in pairs(admins) do
- if tfm.get.room.playerList[i.name]~=nil then
- tfm.exec.chatMessage("<N2>Ξ ["..n.."] !"..c,i.name)
- end
- end
- end
- if not(tonumber(c)==nil) then
- admins[n].type = tonumber(c)
- elseif rules[1] == "reload" then
- recreator=coroutine.create(function()
- while tablelength(recreatingBlocks)~=0 do
- for i=0,blockRespawnRate do
- tfm.exec.removePhysicObject(#recreatingBlocks)
- tfm.exec.addPhysicObject(#recreatingBlocks, recreatingBlocks[#recreatingBlocks]["x"], recreatingBlocks[#recreatingBlocks]["y"], recreatingBlocks[#recreatingBlocks]["defs"])
- recreatingBlocks[#recreatingBlocks]=nil
- if tablelength(recreatingBlocks)==0 then break end
- end
- coroutine.yield()
- end
- end)
- recreatingBlocks=table.clone(tiles)
- recreatingBlocksNumber=tablelength(recreatingBlocks)
- elseif rules[1] == "reset" then
- if adm==n then
- makeMapMaker()
- else
- tfm.exec.chatMessage("<VP>Você precisa ser o master"..c,n)
- end
- elseif rules[1] == "textarea" then
- print(#rules)
- admins[n].panflet=(rules[2] and table.concat(table.slice(rules,2,#rules,1), " ") or "")
- print(admins[n].panflet)
- elseif rules[1] == "t" then
- for i in pairs(admins) do
- if tfm.get.room.playerList[i]~=nil then
- tfm.exec.chatMessage("<CH>Ξ ["..n.."] "..table.concat(table.slice(rules,2,#rules,1), " "),i)
- end
- end
- elseif rules[1] == "adm" then
- if rules[2]==n then tfm.exec.chatMessage("<R>"..getWord(lang,"adm_ERROR_autoDowngrade"),n) return end
- if rules[2]==adm then tfm.exec.chatMessage("<R>"..getWord(lang,"adm_ERROR_supremeDowngrade"),n) return end
- if admins[rules[2]] then
- admins[rules[2]]=nil
- tfm.exec.setNameColor (rules[2], 0xbbbbbb)
- else
- admins[rules[2]]=initAdminData()
- tfm.exec.setNameColor (rules[2], 0x00ff00)
- end
- elseif c == "start" then
- admins[n].type = "start"
- elseif c == "finish" then
- admins[n].type = "finish"
- elseif c == "custom" then
- if admins[n].showingCustom then
- ui.removeTextArea(5,n)
- admins[n].showingCustom=false
- else
- local compose = ""
- for _,i in pairs(definition) do
- compose = compose .. "<a href=\"event:valueChange;" .. i.name .. ";"..i.type.."\">" .. getWord(lang,"custom_"..i.name) .. "</a> "
- end
- ui.addTextArea(5, compose .. " <a href=\"event:import\">"..getWord(lang,"custom_import").."</a>", n, 0, 20, 800, 0, 0x123450, 0x123450, 1, true)
- admins[n].showingCustom=true
- end
- elseif c == "use" then
- admins[n].type = "custom"
- elseif rules[1] == "tp" then
- if nil==rules[2] then
- admins[n].isTeleporting=n
- elseif tfm.get.room.playerList[rules[2]] then
- if nil==rules[3] then
- admins[n].isTeleporting=rules[2]
- else
- tfm.exec.movePlayer(rules[2],tfm.get.room.playerList[rules[3]].x,tfm.get.room.playerList[rules[3]].y,false,0,0,true)
- end
- end
- elseif c == "spawnpoint" then
- admins[n].type = "spawnpoint"
- elseif rules[1]=="fly" then
- local there="no"
- local id_=0
- for id,i in pairs(flyPerm) do
- if i==rules[2] then
- there="yes"
- id_=id
- end
- end
- if there=="yes" then
- flyPerm[id_]=nil
- else
- flyPerm[#flyPerm+1]=rules[2]
- end
- elseif rules[1]=="spectator" then
- if spection[rules[2]] then
- spection[rules[2]]=nil
- else
- spection[rules[2]]=true
- tfm.exec.killPlayer(rules[2])
- end
- eventPlayerDied(rules[2])
- end
- end
- end,n,c)
- if not(sucess) then tfm.exec.chatMessage("editor crashou... Envie o motivo do crash ao Jellymichey#0000<br>"..status) unload() end
- end
- function eventLoop(p)
- local sucess,status=pcall(function(p)
- if isOnMenu==true then
- if p>4000 then --controls the acess to load the map
- ui.updateTextArea(4,"<p align=\"center\"><a href=\"event:start\">"..getWord(lang,"settings_START").."</a></p>")
- end
- end
- if not(finish=="nil") then
- for i,v in pairs(tfm.get.room.playerList) do
- if (not v.hasCheese) or (not cheeseRequired) then
- if v["x"] < finish[1]+40 and v["x"] > finish[1]-0 and v["y"] < finish[2]+40 and v["y"] > finish[2]-0 and (not v.isDead) then
- tfm.exec.giveCheese(i)
- if not cheeseRequired then
- tfm.exec.playerVictory(i)
- tfm.get.room.playerList[i].y=tfm.get.room.playerList[i].y+400
- playerData[i].spawnpointPlayers.place="nil"
- end
- end
- else
- if v["x"] < start[1]+40 and v["x"] > start[1]-0 and v["y"] < start[2]+40 and v["y"] > start[2]-0 and (not v.isDead) then
- tfm.exec.playerVictory(i)
- end
- end
- end
- end
- if recreator~=nil then
- if coroutine.status(recreator)~="dead" then
- coroutine.resume(recreator)
- print("re")
- if coroutine.status(recreator)=="dead" then
- for _,v in pairs(playersEntered) do
- ui.updateTextArea(-3,"<p align=\"center\"><font size=\"20\">pronto!</p>",v)
- if not(start=="nil") then
- ui.addTextArea (0, "", v, start[1]+13, start[2]+13, 25, 25, 0xff0000, 0xff0000, 1, false)
- end
- if not(finish=="nil") then
- print("fnish")
- ui.addTextArea (1, "", v, finish[1]+13, finish[2]+13, 25, 25, 0x00ff00, 0x00ff00, 1, false)
- end
- for i,v in pairs(spawnpointTiles) do
- ui.addTextArea (v.textarea, "", nil, v["x"]-10, v["y"]-10, 25, 25, 0xffff00, 0xffff00, 1, false)
- end
- for i,v in pairs(textareas) do
- ui.addTextArea (v.textarea, v.text, nil, v["x"], v["y"], 0, 0, 0x111111, 0x111111, 1, false)
- end
- eventPlayerDied(v)
- print(v)
- end
- playersEntered={}
- else
- print("load")
- ui.updateTextArea(-3,"<p align=\"center\"><font size=\"20\">"..getWord(lang,"mapLoader").."</font><br><br>"..string.rep("▓",math.ceil((recreatingBlocksNumber-tablelength(recreatingBlocks))/recreatingBlocksNumber*30))..string.rep("░",math.floor((tablelength(recreatingBlocks))/recreatingBlocksNumber*30)).."</p>",v)
- end
- else
- ui.removeTextArea(-3)
- end
- end
- if mapCreator~=nil then
- if coroutine.status(mapCreator)~="dead" then
- coroutine.resume(mapCreator)
- end
- end
- for i,v in pairs(admins) do
- if v.timeSinceTyped<os.time()-2000 then
- ui.removeTextArea(-1,i)
- end
- end
- end,p)
- if not(sucess) then tfm.exec.chatMessage("editor crashou...<br> Envie o motivo do crash ao Jellymichey#0000: "..status) unload() end
- end
- function eventPopupAnswer( id, j, r)
- if id==5 then
- admins[j].customnized[admins[j].callingValue]=(r=="yes")
- end
- print(tonumber(r))
- if not(tonumber(r)==nil) then
- if id==0 then
- widesness=math.max(800,tonumber(r))
- end
- if id==1 then
- heightness=math.max(400,tonumber(r))
- end
- if id==2 then
- admins[j].customnized[admins[j].callingValue]=r
- end
- if id==3 then
- gravityFactor["gravity"]=tonumber(r)
- end
- if id==4 then
- gravityFactor["wind"]=tonumber(r)
- end
- end
- end
- function eventChatMessage(j,c)
- if scrambledText~=nil then
- if c==scrambledText then
- scrambledText=nil
- adm=j
- flyPerm={adm}
- admins={[adm]=initAdminData()}
- ui.addTextArea(1, 'beware of '..adm.."...", nil, 0, 250, 400, 0, 0x123450, 0x123450, 1, false)
- ui.addTextArea(1, '!number -> select block<br>!start -> starting point<br>!finish -> ending point<br>!spawnpoint -> creates spawnpoint<br>!fly player#0000 ->set a player to fly<br>!reset -> resets map', adm, 0, 250, 400, 0, 0x123450, 0x123450, 1, false)
- makeMapMaker(true)
- end
- end
- end
- function eventColorPicked ( id, j, c)
- if c==-1 then return false end
- admins[j].customnized[admins[j].callingValue]=tostring(c)
- end
- for i in pairs(tfm.get.room.playerList) do --players init
- eventNewPlayer(i)
- end
- tfm.exec.setRoomMaxPlayers(25)
- for _, v in next, {"start","spawnpoint","reset","finish","fly","adm","custom","use","tp","t","spectator","textarea","reload"} do
- system.disableChatCommandDisplay(v)
- end
- for i in pairs(prop) do system.disableChatCommandDisplay(tostring(i)) end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement