• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Parsers for 1.2

Codex NG

Recurrent Flamer
Joined
Jul 24, 2015
Messages
2,994
Solutions
12
Reaction score
1,657
Just a few tools I rebuilt in a lua interpreter to get certain values from files, their basically built the same way.
Monster
Code:
    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
Code:
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
Code:
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()
 
Yea the items parser can be used for anything, movements, actions, pretty much anything which is xml in tfs.


I remember I was working on the exact same thing before I left. I'm just glad someone decided to release to the public!
 
I remember I was working on the exact same thing before I left. I'm just glad someone decided to release to the public!
Got some more tools now too :) Their just not public, but also they probably are of no use to anyone either lol
 
Looking at this, I'm wondering if its possible to get values from there: Field Project

and modify monsters listed in this list for example. If Walks around poison then insert into monstername.xml flag value like: <flag walkonpoison="0">, when there is no info then just ignore it.

I could do this basing on your upper code, but I have no idea how to retrieve informations from this site.
 
Looking at this, I'm wondering if its possible to get values from there: Field Project

and modify monsters listed in this list for example. If Walks around poison then insert into monstername.xml flag value like: <flag walkonpoison="0">, when there is no info then just ignore it.

I could do this basing on your upper code, but I have no idea how to retrieve informations from this site.

I love the way you are going with that train of thought. Off hand myself I am not sure how I would want to go with it, either using a webserver to pull the information or grep (tool built-in to linux).
 
Looking at this, I'm wondering if its possible to get values from there: Field Project

and modify monsters listed in this list for example. If Walks around poison then insert into monstername.xml flag value like: <flag walkonpoison="0">, when there is no info then just ignore it.

I could do this basing on your upper code, but I have no idea how to retrieve informations from this site.
Already done:
Fix monsters walking over fields. by Mkalo · Pull Request #2207 · otland/forgottenserver · GitHub
 
Back
Top