Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- blue = false
- orange = false
- checkPoint = {}
- powerUp = {}
- respawn = {}
- xml = false
- loaded = true
- function geraXml(xml)
- local blue = false
- local orange = false
- local checkPoint = {}
- local powerUp = {}
- local respawn = {}
- local pisos = string.match(xml, "<S>.-</S>")
- local novosPisos = ""
- if pisos then
- pisos = pisos:sub(4,-5)
- for v in string.gmatch(pisos, "<S.-/>") do
- local xx = tonumber(string.match(v, 'X=".-"'):sub(4,-2))
- local yy = tonumber(string.match(v, 'Y=".-"'):sub(4,-2))
- local ll = tonumber(string.match(v, 'L=".-"'):sub(4,-2))
- local hh = tonumber(string.match(v, 'H=".-"'):sub(4,-2))
- if string.find(v, 'T="8"') then
- table.insert(checkPoint, {x=xx, y=yy, l=ll, h=hh})
- else
- novosPisos = novosPisos .. v
- end
- end
- else
- print("<r>Erro: Não há pisos.")
- return false
- end
- local objetos = string.match(xml, "<O>.-</O>")
- local novosObjetos = ""
- if objetos then
- objetos = objetos:sub(4,-5)
- for v in string.gmatch(objetos, "<O.-/>") do
- local xx = tonumber(string.match(v, 'X=".-"'):sub(4,-2))
- local yy = tonumber(string.match(v, 'Y=".-"'):sub(4,-2))
- if string.find(v, 'C="15"') then
- table.insert(powerUp, {x=xx, y=yy})
- elseif string.find(v, 'C="16"') then
- blue = {x=xx, y=yy}
- elseif string.find(v, 'C="13"') then
- orange = {x=xx, y=yy}
- else
- novosObjetos = novosObjetos .. v
- end
- end
- else
- print("<r>Erro: Não há objetos de shaman.")
- return false
- end
- local decoracao = string.match(xml, "<D>.-</D>")
- local primeira = true
- local toca = true
- primeiroPlano = false
- if decoracao then
- decoracao = decoracao:sub(4,-5)
- for v in string.gmatch(decoracao, "<T.-/>") do
- if primeira then
- primeira = false
- if string.find(v, 'D=""') then
- primeiroPlano = true
- end
- end
- local xx = tonumber(string.match(v, 'X=".-"'):sub(4,-2))
- local yy = tonumber(string.match(v, 'Y=".-"'):sub(4,-2))
- table.insert(respawn, {x=xx, y=yy})
- end
- else
- print("<r>Erro: Não há decorações.")
- return false
- end
- l = string.match(xml, 'Laps="%d-"')
- if l then
- l = l:sub(7,-2)
- laps = tonumber(l)
- else
- laps = 3
- end
- if blue and not orange then
- print("<j>Aviso: Não há portal laranja.")
- end
- if orange and not blue then
- print("<j>Aviso: Não há portal laranja.")
- end
- if #respawn ~= #checkPoint then
- print("<r>Erro: Quantidade de respawns é diferente de checkpoints.")
- return false
- elseif #powerUp == 0 then
- print("<r>Erro: Não há powerups.")
- return false
- elseif #checkPoint < 3 then
- print("<r>Erro: Menos de 3 checkpoints.")
- return false
- end
- for i, v in pairs(checkPoint) do
- if respawn[i].x < v.x-v.l or respawn[i].x > v.x+v.l or respawn[i].y < v.y-v.h or respawn[i].y > v.y+v.h then
- tfm.exec.chatMessage(string.format("<j>Aviso: Respawn %d não está dentro do checkpoint %d.", i, i))
- end
- end
- xml = xml:gsub("<S>.-</S>", "<S>"..novosPisos.."</S>")
- xml = xml:gsub("<O>.-</O>", "<O>"..novosObjetos.."</O>")
- xml = xml:gsub("<T.-/>", function(a)
- if toca then
- toca = false
- return a
- else
- return ""
- end
- end)
- return xml, checkPoint, powerUp, respawn, blue, orange
- end
- function eventNewGame()
- xml = false
- if loaded then
- loaded = false
- if tfm.get.room.currentMap:sub(1,1) == "@" then
- tfm.exec.setUIMapName(author.."<bl> - "..code)
- for i, v in pairs(checkPoint) do
- local txt = i
- for j=1, 200 do
- txt = txt .. " " .. i
- end
- ui.addTextArea(i, "<font size='40px' color='#ffffff'>"..txt, nil, v.x+5-v.l/2, v.y+5-v.h/2, v.l-10, v.h-10, 0xffffff, 0xffffff, 0.2, false)
- end
- for i, v in pairs(powerUp) do
- ui.addTextArea(i+100, "<font size='15px' color='#ffff00'><p align='center'><b>?", nil, v.x+5-16, v.y+5-16, 22, 22, 0xffff00, 0xffff00, 0.5, false)
- end
- for i, v in pairs(respawn) do
- ui.addTextArea(i+200, "<font size='15px' color='#00ff00'><p align='center'><b>"..i, nil, v.x+5-16, v.y+5-31, 22, 22, 0x00ff00, 0x00ff00, 0.5, false)
- end
- if blue then
- tfm.exec.addShamanObject(26, blue.x, blue.y, 0, 0, 0, false)
- end
- if orange then
- tfm.exec.addShamanObject(27, orange.x, orange.y, 0, 0, 0, false)
- end
- end
- else
- xml, checkPoint, powerUp, respawn, blue, orange = geraXml(tfm.get.room.xmlMapInfo.xml)
- loaded = true
- code = tfm.get.room.currentMap
- author = tfm.get.room.xmlMapInfo.author
- if xml then
- tfm.exec.newGame(xml)
- else
- tfm.exec.newGame(0)
- end
- end
- end
- tfm.exec.disableAutoShaman(true)
- tfm.exec.disableAutoNewGame(true)
- tfm.exec.newGame(0)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement