Ir para conteúdo

Parsers


Administrador

Posts Recomendados

  • Administrador

Apenas algumas ferramentas que o Codex NG reconstruiu em um interpretador Lua para obter certos valores a partir de arquivos.

 

Monster

 local data = {
        ['monster'] = {'name', 'nameDescription', 'race', 'experience', 'speed', 'manacost', 'skull', 'script'},
        ['health'] = {'min', 'max'},
        ['look'] =  { 'type', 'head', 'body', 'legs', 'feet', 'corpse', 'addons', 'typeex', 'mount'},
        ['targethange'] = { 'interval', 'chance', 'speed'},
        ['flag'] = {'summonable', 'attackable', 'hostile', 'illusionable', 'convinceable', 'pushable', 'canpushitems',
        'canpushcreatures', 'staticattack', 'lightlevel', 'lightcolor', 'targetdistance', 'runonhealth', 'hidehealth'},
        ['attack'] = {'name', 'interval', 'min', 'max', 'range', 'chance'},
        ['attribute'] = {'key', 'value'},
        ['defenses'] ={'armor', 'defense'},
        ['element'] = {'physicalPercent', 'icePercent', 'poisonPercent', 'earthPercent', 'firePercent', 'energyPercent',
        'holyPercent', 'deathPercent', 'drownPercent', 'lifedrainPercent', 'manadrainPercent'},
        ['immunity'] = {'name', 'physical', 'energy', 'fire', 'poison', 'earth', 'drown', 'ice', 'holy', 'death',
        'lifedrain', 'manadrain', 'paralyze', 'outfit', 'drunk', 'invisible', 'invisibility', 'bleed'},
        ['voices'] = {'speed', 'interval', 'chance', 'sentence', 'yell'},
        ['voice'] = {'speed', 'interval', 'chance', 'sentence', 'yell'},
        ['summons'] = {'maxSummons'},
        ['summon'] = {'name','interval','chance','speed'},
        ['script'] = {'name'},
        ['item'] = {'id','countmax','chance', 'chance1', 'subtype', 'actionId', 'text'}
    }


    local dir = 'data/monster/'
    local file = 'monsters.xml'


    for line in io.lines(dir..file) do
        if string.match(line, '<(%a-)%s* ') ~= nil then
           for lines in io.lines(dir..line:match('file="(.-)"') ) do
                if string.match(lines, '<(%a-)%s* ') ~= nil then
                    local p = data[string.match(lines, '<(%a-)%s* ')]
                    if p ~= nil then
                        for i = 1, #p do
                            local t = lines:match(p[i]..'="(.-)"')
                            if t ~= nil then
                                print(string.match(lines, '<(%a-)%s* '), p[i], t)
                            end
                        end
                    end
                end
           end
        end
    end

Items

local items = {}
local para = {
    'id', 'name', 'fromid', 'toid', 'key', 'value'
    }

function Items()
    local file = 'data/items/items.xml'

    local k = {}

    for line in io.lines(file) do
        if string.match(line, '<(%a-)%s* ') ~= nil then
            local itemParam =  string.match(line, '<(%a-)%s* ')
            if itemParam ~= nil then
                for type_ in line:gmatch(itemParam) do
                    for i = 1, #para do
                        if line:match(para[i]..'="(.-)"') then
                            table.insert(k, para[i]..' = "'..line:match(para[i]..'="(.-)"')..'", ')
                        end
                    end
                    local temp = '{'..table.concat(k)
                    temp = temp:sub(1, #temp - 2)..'},'
                    k = {}
                    table.insert(items, temp)
                end
            end
        end
    end
    for k, v in pairs(items)do
        print(v)
    end
end
Items()

Spells

local spells = {}
local para = {
    'group', 'spellid', 'name', 'words', 'lvl', 'mana', 'prem', 'range', 'needtarget', 'blockwalls',
    'needweapon', 'exhaustion', 'groupcooldown', 'casterTargetOrDirection', 'aggressive', 'needlearn',
    'selftarget', 'script', 'charges', 'maglv'
    }

function parseSpells()
    local file = 'data/spells/spells.xml'

    local k = {}

    for line in io.lines(file) do
        if string.match(line, '<(%a-)%s* ') ~= nil then
            spellParam =  string.match(line, '<(%a-)%s* ')
            if spellParam ~= nil then
                for type_ in line:gmatch(spellParam) do
                    for i = 1, #para do
                        if line:match(para[i]..'="(.-)"') then
                            table.insert(k, para[i]..' = "'..line:match(para[i]..'="(.-)"')..'", ')
                        end
                    end
                    local temp = '{'..table.concat(k)
                    temp = temp:sub(1, #temp - 2)..'},'
                    k = {}
                    table.insert(spells, temp)
                end
            end
        end
    end
    for k, v in pairs(spells)do
        print(v)
    end
end
parseSpells()
Link para o comentário
Compartilhar em outros sites

×
×
  • Criar Novo...