Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local maps = {
- '<C><P /><Z><S><S L="200" Y="300" P="0,0,0.3,0.2,0,0,0,0" T="0" X="400" H="50" /></S><D><T X="350" Y="275" /><F X="450" Y="270" /></D><O /></Z></C>'
- }
- local holeX
- local holeY
- function main()
- tfm.exec.disableAutoNewGame(true)
- tfm.exec.newGame(maps[math.random(#maps)])
- end
- function eventNewGame()
- local xml = tfm.get.room.xmlMapInfo.xml
- xmldom = parseXml(xml)
- for _,s in ipairs(path(xmldom, "Z", "D", "T")) do
- local ss = s.attribute
- holeX = ss.X
- holeY = ss.Y
- end
- end
- function eventSummoningEnd(name, object, x, y, angle, xSpeed, ySpeed, objectType, other)
- if pythag(holeX, holeY, x, y, 30) then
- for name, player in pairs(tfm.get.room.playerList) do
- if player.isShaman then
- tfm.exec.killPlayer(name)
- end
- end
- end
- end
- function pythag(x1,y1,x2,y2,r)
- local x=x2-x1
- local y=y2-y1
- local r=r+r
- return x*x+y*y<r*r
- end
- -- Makinit's XML Library
- do
- local namePattern = "[%a_:][%w%.%-_:]*"
- function parseXml(xml)
- local root = {}
- local parents = {}
- local element = root
- for closing, name, attributes, empty, text in string.gmatch(xml, "<(/?)(" .. namePattern .. ")(.-)(/?)>%s*([^<]*)%s*") do
- if closing == "/" then
- local parent = parents[element]
- if parent and name == element.name then
- element = parent
- end
- else
- local child = {name = name, attribute = {}}
- table.insert(element, child)
- parents[child] = element
- if empty ~= "/" then
- element = child
- end
- for name, value in string.gmatch(attributes, "(" .. namePattern .. ")%s*=%s*\"(.-)\"") do
- child.attribute[name] = value
- end
- end
- if text ~= "" then
- local child = {text = text}
- table.insert(element, child)
- parents[child] = element
- end
- end
- return root[1]
- end
- function path(nodes, ...)
- nodes = {nodes}
- for i, name in ipairs(arg) do
- local match = {}
- for i, node in ipairs(nodes) do
- for i, child in ipairs(node) do
- if child.name == name then
- table.insert(match, child)
- end
- end
- end
- nodes = match
- end
- return nodes
- end
- end
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement