Resources Library

zetaepyon edited this page Jan 9, 2018 · 1 revision

A library that handles FFXI resources (tables containing in-game data) and provides helper functions to work with them. When required, no resources are loaded, they are only loaded on demand. The available resources can be found in the resources directory (Windower/res/) and are available as sub-tables of the required res table.

Usage

res = require('resources')

Structure

All resources are indexed by their in-game ID (usually what the packets use to refer to a certain resource). So res.items[19747] would retrieve the resource-table of the item with ID 19747 (in this case Mandau 99). Every such resource-table has various entries that relate to the resource, and it depends on the type of the resource in question.

The general structure of the resources can be gleaned by checking out the respective Lua file in the resources directory. However, there are some deviations. For example, the Lua files use the ISO 639-1 language code for English (en), Japanese (ja), German (de), French (fr), however, in the parsed resources they will appear under their full english names (english, japanese, german and french). Also, a new field name will be added, which is an alias to whatever the addon's language is, or, if none is provided for the addon, what the user's POL language is.

A few fields from the Lua files will be transformed. For example, job_abilities and spells have a targets field, which contains a number. This number is a bit field, a binary encoding of viable targets for the ability/spell in question. When parsed, targets will be a set of valid targets. For example, Cover (job ability with ID 79) has a targets value of 5 in the Lua file. However, when used from within an addon, the result is as follows:

res.job_abilities[79].targets == S{'Self', 'Party'}

So it's translated into a set of valid values. The same is true for certain other fields, like jobs and races inside res.items.

Usage examples

If you want to make an AutoExec-like addon that inputs certain commands on job change, you could do the following:

windower.register_event('job change', function(job_id)
    local job = res.jobs[job_id].english_short
    if job == 'WAR' then
        windower.send_command('input /macro book 1')
    elseif job == 'THF' then
        windower.send_command('input /macro book 2')
    end
end

Assume you want to find the ID of an item with a certain name. You can use the :with method to retrieve the table matching the provided value. The following code demonstrates it:

local ridill = res.items:with('name', 'Ridill')
print(ridill.id, ridill.damage)

If you want multiple resources matching certain criteria, you can use any of the resource-specific fields as a method. For example, res.buffs elements have a duration field that describes how long the buff/debuff will last. If you want all buffs that have a duration of 3 minutes (180 seconds), you can use the following:

res.buffs:duration(180)

If you want all buffs with at least a 3 minute duration, you can provide a function instead of just a value:

res.buffs:duration(function(buff)
    return buff.duration >= 180
end)

This will go through every buff in res.buffs and apply it to the function. If the function returns true, it accepts it, if not it filters it out. The result is a list of buffs matching the desired criterium.

You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.