Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- groundsTable = {}
- selectedGround = false
- tfm.exec.disableAutoShaman(true)
- function split(str)
- tok = {}
- for token in string.gmatch(str, "[^%s]+") do
- table.insert(tok,token)
- end
- str = tok[1]
- tok = {}
- for a in string.gmatch(str,'[^,]+') do
- table.insert(tok,a)
- end
- return tok
- end
- function parseXml(shaman)
- vanillaGrounds = ''
- groundsTable = {}
- if tfm.get.room.xmlMapInfo.xml then
- c = 0
- xml = tfm.get.room.xmlMapInfo.xml
- grounds = xml:match('<S>[^´]+/>'):gsub("<S>","")
- for id in grounds:gmatch('<S[^/]+/>') do
- c = c+1
- groundsTable[c] = {id = c,
- L = id:match('L="[0-9-]+"'):gsub("L=",""):gsub('"',""),
- H = id:match('H="[0-9-]+"'):gsub("H=",""):gsub('"',""),
- X = id:match('X="[0-9-]+"'):gsub("X=",""):gsub('"',""),
- Y = id:match('Y="[0-9-]+"'):gsub("Y=",""):gsub('"',""),
- T = id:match('T="[0-9-]+"'):gsub("T=",""):gsub('"',""),
- O = '0'
- }
- if groundsTable[c].T == "12" or groundsTable[c].T == "13" then
- groundsTable[c].O = id:match('o="[A-Za-z0-9]+"'):gsub("o=",""):gsub('"',"")
- end
- groundsTable[c].OTHERS = split(id:match('P="[^¨]+"'):gsub("P=",""):gsub('"',""))
- id = id:gsub('X=',string.format('lua="%s" X=',c))
- vanillaGrounds = vanillaGrounds..id
- end
- xmlStart = xml:match('<C>[^´]+<S>')
- xmlEnd = xml:match('</S>[^´]+</C>')
- xml = string.format("%s%s%s",xmlStart,vanillaGrounds,xmlEnd)
- tfm.exec.newGame(xml)
- tfm.exec.setShaman(shaman)
- system.bindMouse(shaman)
- print('<ROSE>[Game]<N> Agora é o seu turno! Utilize o mouse para mover os pisos.')
- end
- end
- function eventSummoningEnd(playerName, objectType, xPosition, yPosition, angle, xSpeed, ySpeed, other)
- tfm.exec.removeObject(other.id)
- end
- function getShamanRoom()
- sc = {score = 0, name = 'Souris'}
- for k,v in pairs(tfm.get.room.playerList) do
- system.bindMouse(k,false)
- if v.score >= sc.score then
- sc = {score = v.score, name = k}
- end
- end
- tfm.exec.setPlayerScore(sc.name,0)
- return sc.name
- end
- function eventNewGame()
- if tfm.get.room.xmlMapInfo.xml then
- mapAuthor = tfm.get.room.xmlMapInfo.author
- if mapAuthor ~= '#Module' then
- parseXml(getShamanRoom())
- end
- end
- end
- function eventMouse(player,x,y)
- if not selectedGround then
- for id,tabl in pairs(groundsTable) do
- if x > tabl.X-tabl.L/2 and x < tabl.X+tabl.L/2 and y > tabl.Y-tabl.H/2 and y < tabl.Y+tabl.H/2 then
- ui.addTextArea(1,'',nil,tabl.X-tabl.L/2,tabl.Y-tabl.H/2,tabl.L,tabl.H,0xFEFF00,0xFEFF00,0.2,false)
- selectedGround = id
- end
- end
- else
- tfm.exec.addPhysicObject(selectedGround,x,y,{color = '0x'..groundsTable[selectedGround].O, type = groundsTable[selectedGround].T, width = groundsTable[selectedGround].L, height = groundsTable[selectedGround].H, mass = groundsTable[selectedGround].OTHERS[1], friction = groundsTable[selectedGround].OTHERS[3], restitution = groundsTable[selectedGround].OTHERS[4], angle = groundsTable[selectedGround].OTHERS[5]})
- groundsTable[selectedGround].X = x
- groundsTable[selectedGround].Y = y
- selectedGround = false
- ui.removeTextArea(1)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement