Path of Exile Wiki

Please consider helping keep the wiki up to date. Check the to-do list of updates needed for version 3.14.0.

Game data exports will becoming later as the technical changes in addition to regular changes take some more time.

READ MORE

Path of Exile Wiki
Register
m (OmegaK2 moved page Module:Quest rewards to Module:Quest reward without leaving a redirect: Consistency with other module names (singular))
No edit summary
Line 17: Line 17:
 
},
 
},
 
messages = {
 
messages = {
storage = 'Stored %s rows in "%s" table',
+
storage = 'Attempted to store %s rows in "%s_rewards" table',
 
},
 
},
 
}
 
}
Line 123: Line 123:
 
 
 
-- mw.loadData has some problems...
 
-- mw.loadData has some problems...
local data = require(string.format('Module:Quest rewards/data/%s', tpl_args.tbl))
+
local data = require(string.format('Module:Quest reward/data/%s', tpl_args.tbl))
 
for i=tpl_args.index_start or 1, tpl_args.index_end or #data do
 
for i=tpl_args.index_start or 1, tpl_args.index_end or #data do
 
local row = data[i]
 
local row = data[i]

Revision as of 17:08, 28 April 2018

--
-- Module for bestiary templates
--

local m_util = require('Module:Util')
local getArgs = require('Module:Arguments').getArgs

local p = {}

-- ----------------------------------------------------------------------------
-- Strings
-- ----------------------------------------------------------------------------

local i18n = {
    errors = {
        invalid_table = 'Invalid table selected. Valid choices are either quest or vendor',
    },
    messages = {
        storage = 'Attempted to store %s rows in "%s_rewards" table',
    },
}

-- ----------------------------------------------------------------------------
-- Cargo
-- ----------------------------------------------------------------------------

local tables = {}

tables.quest_rewards = {
    table = 'quest_rewards',
    fields = {
        quest = {
            field = 'quest',
            type = 'String',
        },
        quest_id = {
            field = 'quest_id',
            type = 'Integer',
        },
        -- still needed?
        act = {
            field = 'act',
            type = 'Integer',
        },
        classes = {
            field = 'classes',
            type = 'String',
        },
        sockets = {
            field = 'sockets',
            type = 'Integer',
        },
        page = {
            field = 'page',
            type = 'Page',
        },
        item_level = {
            field = 'item_level',
            type = 'Integer',
        },
        rarity = {
            field = 'rarity',
            type = 'String',
        },
        reward = {
            field = 'reward',
            type = 'String',
        },
    },
}

tables.vendor_rewards = {
    table = 'vendor_rewards',
        quest = {
            field = 'quest',
            type = 'String',
        },
        quest_id = {
            field = 'quest_id',
            type = 'Integer',
        },
        act = {
            field = 'act',
            type = 'Integer',
        },
        reward = {
            field = 'reward',
            type = 'String',
        },
        npc = {
            field = 'npc',
            type = 'String',
        },
        classes = {
            field = 'classes',
            type = 'String',
        },
}

-- ----------------------------------------------------------------------------
-- Helper functions and globals
-- ----------------------------------------------------------------------------

-- ----------------------------------------------------------------------------
-- Page functions
-- ----------------------------------------------------------------------------

local p = {}

p.table_quest_rewards = m_util.cargo.declare_factory{data=tables.quest_rewards}
p.table_vendor_rewards = m_util.cargo.declare_factory{data=tables.vendor_rewards}

function p.store_data(frame)
    -- Get args
    tpl_args = getArgs(frame, {
        parentFirst = true
    })
    frame = m_util.misc.get_frame(frame)
    
    if tables[tpl_args.tbl .. '_rewards'] == nil then
        error(i18n.errors.invalid_table)
    end
    
    -- mw.loadData has some problems...
    local data = require(string.format('Module:Quest reward/data/%s', tpl_args.tbl))
    for i=tpl_args.index_start or 1, tpl_args.index_end or #data do 
        local row = data[i]
        if row == nil then
            break
        end
        -- get full table name
        row._table = tables[tpl_args.tbl .. '_rewards'].table
        m_util.cargo.store(frame, row)
    end
    
    return string.format(i18n.messages.storage, #data, tpl_args.tbl)
end

-- ----------------------------------------------------------------------------
-- End
-- ----------------------------------------------------------------------------

return p