Boa tarde galera, o adm Daniel postou o LUA Parser feito pelo Codex NG (a seguir)
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()
Meu pedido é reestruturá-lo para que fique dessa maneira a saída:
["exori gran ico"] = {group="attack",spellid="62",name="Annihilation",words="exori gran ico",lvl="110",mana="300",prem="1",range="1",needtarget="1",blockwalls="1",needweapon="1",exhaustion="30000",groupcooldown="4000",needlearn="0",script="attack/annihilation.lua", vocations = {"Knight","Elite Knight"}},
isso facilitará minha vida, pq estou mexendo em um spellbar para o OTClient e seria interessante ter um código que atualizasse todas as alterações no meu spells.xml de uma unica vez, pra apenas colar no script do OTClient igual
info
Grupo: Visconde
Registrado: 12/09/10
Posts: 416
Reputação: +160
Char no Tibia: Draky Lucas
Boa tarde galera,
o adm Daniel postou o LUA Parser feito pelo Codex NG (a seguir)
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()Meu pedido é reestruturá-lo para que fique dessa maneira a saída:
["exori gran ico"] = {group="attack",spellid="62",name="Annihilation",words="exori gran ico",lvl="110",mana="300",prem="1",range="1",needtarget="1",blockwalls="1",needweapon="1",exhaustion="30000",groupcooldown="4000",needlearn="0",script="attack/annihilation.lua", vocations = {"Knight","Elite Knight"}},isso facilitará minha vida, pq estou mexendo em um spellbar para o OTClient e seria interessante ter um código que atualizasse todas as alterações no meu spells.xml de uma unica vez, pra apenas colar no script do OTClient igual
Obrigado