Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- base = "123456789abcdefghijklmnopqrstuvwxyzABCDEFGIJKLMNOPQRSTUVWXYZ"
- code = "@5313671"
- adm = "Ninguem" -- mude para seu nick
- change = false
- op = -1
- mirrorX = false
- mirrorY = false
- grid = true
- help = false
- idSelect = 1
- idMirror = 2
- idGrid = 3
- idGridText = 4
- idGridOff = 6
- idHelp = 7
- idHelpText = 8
- idSaveText = 9
- idExitText = 10
- idInfo = 11
- popDelete = 12
- popSave = 13
- popExit = 14
- contObject = 0
- contGround = 0
- contVamp = 0
- contDeath = 0
- contScore = 0
- contSpawn = 0
- ground = {type=0,height=16,width=16,color=0,foreground=true}
- layer = {type=12,height=320,width=640,color=0x6a7495}
- map = {}
- for i = 1, 20 do
- map[i] = {}
- for j = 1, 40 do
- map[i][j] = -1
- end
- end
- tfm.exec.disableAfkDeath(true)
- tfm.exec.disableAutoNewGame(true)
- tfm.exec.disableAutoShaman(true)
- tfm.exec.newGame(code)
- function cont()
- local warnObject = ""
- local warnGround = ""
- local warnScore = ""
- local warnSpawn = ""
- contObject = 0
- contGround = 0
- contVamp = 0
- contDeath = 0
- contScore = 0
- contSpawn = 0
- for i = 1, 20 do
- for j = 1, 40 do
- if map[i][j] ~= -1 then
- contObject = contObject + 1
- if map[i][j] >= 0 and map[i][j] <= 8 then
- contGround = contGround + 1
- elseif map[i][j] == 10 then
- contVamp = contVamp + 1
- elseif map[i][j] == 11 then
- contDeath = contDeath + 1
- elseif map[i][j] == 12 then
- contScore = contScore + 1
- elseif map[i][j] == 13 then
- contSpawn = contSpawn + 1
- end
- end
- end
- end
- if contObject == 0 or contObject > 400 then
- warnObject = "<r>"
- end
- if contGround == 0 then
- warnGround = "<r>"
- end
- if contScore == 0 then
- warnScore = "<r>"
- end
- if contSpawn == 0 then
- warnSpawn = "<r>"
- end
- local info = warnObject.."Objects: "..contObject.."/400\n<n>"..warnGround.."Grounds: "..contGround.."\n<n>Item points: "..contVamp.."\nDeath points: "..contDeath.."\n<n>"..warnScore.."Score points: "..contScore.."\n<n>"..warnSpawn.."Spawn points: "..contSpawn
- ui.addTextArea(idInfo, info, nil, 660, 90, 130, 100, 0, 0, 0, false)
- end
- function generate()
- local text = string.format("%03d", contObject)
- for i = 1, 20 do
- for j = 1, 40 do
- if map[i][j] ~= -1 then
- text = text .. base:sub(i,i) .. base:sub(j,j) .. base:sub(map[i][j]+1,map[i][j]+1)
- end
- end
- end
- print("<j>Paste this XML in Tansformice Map Editor and Export as tribe house.\n<n><<font size='6px'>\n"..[[C><P Ca=""H="800"L="1600"Pw="]]..text..[["/><Z><S/><D/><O/></Z></C]].."\n</font>>")
- end
- function makeGround(x, y, op)
- tfm.exec.addPhysicObject(x*100+y, x*16+2, y*16+22, ground)
- map[y][x] = op
- end
- function eventNewGame()
- change = true
- tfm.exec.setUIMapName("Editor - " .. adm .. "\n")
- ui.addTextArea(idSelect, "", nil, 55, 360, 30, 30, 0, 0xffff00, 0.3, false)
- ui.addTextArea(idMirror, "", nil, 495, 360, 30, 30, 0, 0x0000ff, 0.3, false)
- ui.addTextArea(idInfo, "<r>Objects: 0/400\nGrounds: 0\n<n>Item points: 0\nDeath points: 0\n<r>Score points: 0\nSpawn points: 0", nil, 660, 90, 130, 100, 0, 0, 0, false)
- ui.addTextArea(idGridText, "<p align='center'><font color='#0'><b>Show grid", nil, 660, 30, 130, 20, 0, 0, 0, false)
- ui.addTextArea(idGrid, "", nil, 660, 30, 130, 20, 0, 1, 0.3, false)
- ui.addTextArea(idHelpText, "<p align='center'><font color='#0'><b>Helper friend", nil, 660, 60, 130, 20, 0, 0, 0, false)
- ui.addTextArea(idSaveText, "<p align='center'><font color='#0'><b>Export XML", nil, 660, 345, 130, 20, 0, 0, 0, false)
- ui.addTextArea(idExitText, "<p align='center'><font color='#0'><b>Exit the editor", nil, 660, 375, 130, 20, 0, 0, 0, false)
- for i, v in pairs(tfm.get.room.playerList) do
- system.bindMouse(i, true)
- if i ~= adm then
- tfm.exec.killPlayer(i)
- end
- end
- end
- function eventPopupAnswer(popup, p, a)
- if popup == popDelete and a == "yes" then
- for i = 1, 20 do
- for j = 1, 40 do
- map[i][j] = -1
- tfm.exec.removePhysicObject(j*100+i)
- end
- end
- cont()
- elseif popup == popSave and a == "yes" then
- generate()
- elseif popup == popExit and a == "yes" then
- system.exit()
- end
- end
- function eventMouse(p, x, y)
- if p == adm then
- if x > 10 and x < 650 and y > 30 and y < 350 then
- local xx = math.floor((x-10)/16)+1
- local yy = math.floor((y-30)/16)+1
- if op == -1 then
- tfm.exec.removePhysicObject(xx*100+yy)
- map[yy][xx] = op
- elseif contObject <= 400 then
- if op >= 0 and op <= 8 then
- ground.type = op
- ground.width = 16
- ground.height = 16
- else
- ground.width = 10
- ground.height = 10
- ground.type = 12
- if op == 10 then
- ground.color = 0xFFC300
- elseif op == 11 then
- ground.color = 0xF93801
- elseif op == 12 then
- ground.color = 0xFF00DC
- elseif op == 13 then
- ground.color = 0x78583A
- end
- end
- makeGround(xx, yy, op)
- if mirrorX then
- makeGround(41-xx, yy, op)
- end
- if mirrorY then
- makeGround(xx, 21-yy, op)
- end
- if mirrorY and mirrorX then
- makeGround(41-xx, 21-yy, op)
- end
- end
- elseif x > 660 and x < 790 then
- if y > 30 and y < 50 then
- if grid then
- grid = false
- ui.removeTextArea(idGrid, nil)
- tfm.exec.addPhysicObject(idGridOff, 330, 190, layer)
- else
- grid = true
- ui.addTextArea(idGrid, "", nil, 660, 30, 130, 20, 0, 1, 0.3, false)
- tfm.exec.removePhysicObject(idGridOff)
- end
- elseif y > 60 and y < 80 then
- if help then
- help = false
- ui.removeTextArea(idHelp, nil)
- else
- help = true
- ui.addTextArea(idHelp, "", nil, 660, 60, 130, 20, 0, 1, 0.3, false)
- end
- elseif y > 340 and y < 370 then
- if contObject <= 400 and contGround > 0 and contScore > 0 and contSpawn > 0 then
- ui.addPopup(popSave, 1, "<p align='center'>Ready for the flood?", adm, 250, 200, 300, true)
- else
- ui.addPopup(popSave, 0, "<p align='center'>The map can't be so. Look the informations in red.", adm, 250, 200, 300, true)
- end
- elseif y > 370 and y < 400 then
- ui.addPopup(popExit, 1, "<p align='center'>Exit the editor?", adm, 250, 200, 300, true)
- end
- elseif y > 360 and y < 390 then
- if x > 15 and x < 45 then
- ui.addPopup(popDelete, 1, "<p align='center'>Delete all objects?", adm, 250, 200, 300, true)
- elseif x > 55 and x < 85 then
- ui.addTextArea(idSelect, "", nil, 55, 360, 30, 30, 0, 0xffff00, 0.3, false)
- op = -1
- elseif x > 95 and x < 125 then
- ui.addTextArea(idSelect, "", nil, 95, 360, 30, 30, 0, 0xffff00, 0.3, false)
- op = 0
- elseif x > 135 and x < 165 then
- ui.addTextArea(idSelect, "", nil, 135, 360, 30, 30, 0, 0xffff00, 0.3, false)
- op = 1
- elseif x > 175 and x < 205 then
- ui.addTextArea(idSelect, "", nil, 175, 360, 30, 30, 0, 0xffff00, 0.3, false)
- op = 2
- elseif x > 215 and x < 245 then
- ui.addTextArea(idSelect, "", nil, 215, 360, 30, 30, 0, 0xffff00, 0.3, false)
- op = 3
- elseif x > 255 and x < 285 then
- ui.addTextArea(idSelect, "", nil, 255, 360, 30, 30, 0, 0xffff00, 0.3, false)
- op = 4
- elseif x > 295 and x < 325 then
- ui.addTextArea(idSelect, "", nil, 295, 360, 30, 30, 0, 0xffff00, 0.3, false)
- op = 8
- elseif x > 335 and x < 365 then
- ui.addTextArea(idSelect, "", nil, 335, 360, 30, 30, 0, 0xffff00, 0.3, false)
- op = 10
- elseif x > 375 and x < 405 then
- ui.addTextArea(idSelect, "", nil, 375, 360, 30, 30, 0, 0xffff00, 0.3, false)
- op = 11
- elseif x > 415 and x < 445 then
- ui.addTextArea(idSelect, "", nil, 415, 360, 30, 30, 0, 0xffff00, 0.3, false)
- op = 12
- elseif x > 455 and x < 485 then
- ui.addTextArea(idSelect, "", nil, 455, 360, 30, 30, 0, 0xffff00, 0.3, false)
- op = 13
- elseif x > 495 and x < 525 then
- ui.addTextArea(idMirror, "", nil, 495, 360, 30, 30, 0, 0x0000ff, 0.3, false)
- mirrorX = false
- mirrorY = false
- elseif x > 535 and x < 565 then
- ui.addTextArea(idMirror, "", nil, 535, 360, 30, 30, 0, 0x0000ff, 0.3, false)
- mirrorX = true
- mirrorY = false
- elseif x > 575 and x < 605 then
- ui.addTextArea(idMirror, "", nil, 575, 360, 30, 30, 0, 0x0000ff, 0.3, false)
- mirrorX = false
- mirrorY = true
- elseif x > 615 and x < 645 then
- ui.addTextArea(idMirror, "", nil, 615, 360, 30, 30, 0, 0x0000ff, 0.3, false)
- mirrorX = true
- mirrorY = true
- end
- end
- cont()
- elseif help then
- tfm.exec.displayParticle(0, x, y, 0, 0, 0, 0, nil)
- end
- end
- function eventLoop(current,remaining)
- if not change then
- tfm.exec.newGame(code)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement