Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Creator: Bolodefchoco
- --Made in: 27/01/2017
- --Last update: 27/01/2017
- --[[ Notes:
- Example:
- eventNewGame = function()
- local currentXml = xml.addAttrib(tfm.get.room.xmlMapInfo.xml or "",{{tag="BD",value=""},{tag="BN",value="1"}},false)
- xml.attribFunc(currentXml or "",{
- [1] = {
- attribute = "meep",
- func = function()
- for n in next,tfm.get.room.playerList do
- tfm.exec.giveMeep(n)
- end
- end
- },
- [2] = {
- attribute = "cheese",
- func = function()
- for n in next,tfm.get.room.playerList do
- tfm.exec.giveCheese(n)
- end
- end
- },
- [3] = {
- attribute = "vamp",
- func = function(player)
- tfm.exec.movePlayer(player,20,30)
- tfm.exec.setVampirePlayer(player)
- end
- },
- [4] = {
- attribute = "mapname",
- func = function(text)
- ui.setMapName(text)
- end
- },
- [5] = {
- attribute = "BN",
- func = function(text)
- ui.setShamanName(text)
- end
- },
- })
- end
- xmlmap = '<C><P meep="" vamp="Bolodefchoco" cheese="" l="a" b="123,546;12" teste="" d="213" D="5156,5" /><Z><S><S L="930" H="62" X="426" Y="420" T="0" P="0,0,0.3,0.2,0,0,0,0" /></S><D /><O /></Z></C>'
- tfm.exec.newGame(xmlmap)
- ]]--
- xml = {}
- xml.parse = function(currentXml)
- currentXml = currentXml:match("<P (.-)/>") or ""
- local out = {}
- for tag,_,value in currentXml:gmatch("([%-%w]+)=([\"'])(.-)%2") do
- out[tag] = value
- end
- return out
- end
- xml.attribFunc = function(currentXml,funcs)
- local attributes = xml.parse(currentXml)
- for k,v in next,funcs do
- if attributes[v.attribute] then
- v.func(attributes[v.attribute])
- end
- end
- end
- xml.addAttrib = function(currentXml,out,launch)
- local parameters = currentXml:match("<P (.-)/>") or ""
- for k,v in next,out do
- if not parameters:find(v.tag) then
- currentXml = currentXml:gsub("<P (.-)/>",function(attribs)
- return string.format("<P %s=\"%s\" %s/>",v.tag,v.value,attribs)
- end)
- end
- end
- if launch then
- tfm.exec.newGame(currentXml)
- else
- return currentXml
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement