Module:Map series

From Path of Exile 2 Wiki
Jump to navigation Jump to search
Module documentation[view] [edit] [history] [purge]


Lua logo

This module depends on the following other modules:

The actual list of map series is stored in Module:Map series/map series

Subpages

Usage

{{#invoke:Map series|function_name}}

-------------------------------------------------------------------------------
-- 
--                              Module:Map series
-- 
-------------------------------------------------------------------------------

require('Module:No globals')
local m_cargo = require('Module:Cargo')

-- ----------------------------------------------------------------------------
-- Cargo tables
-- ----------------------------------------------------------------------------

local tables = {}

tables.map_series = {
    table = 'map_series',
    order = {'ordinal', 'id', 'name'},
    fields = {
        ordinal = {
            field = 'ordinal',
            type = 'Integer',
        },
        id = {
            field = 'id',
            type = 'String',
        },
        name = {
            field = 'name',
            type = 'String',
        },
    },
}

-- ----------------------------------------------------------------------------
-- Exported functions
-- ----------------------------------------------------------------------------

local p = {}

p.table_map_series = m_cargo.declare_factory{data=tables.map_series}

p.store_data = m_cargo.store_from_lua{tables=tables, module='Map series'}

function p.current_map_series()
    local results = m_cargo.query(
        {tables.map_series.table},
        {tables.map_series.fields.name.field},
        {
            orderBy = tables.map_series.fields.ordinal.field .. ' DESC',
            limit = 1,
        }
    )
    if #results < 1 then
        error('No map series found.')
    end
    return results[1].name
end

return p