Module:Quest reward: Difference between revisions
Jump to navigation
Jump to search
>OmegaK2 No edit summary |
>OmegaK2 No edit summary |
||
Line 50: | Line 50: | ||
field = 'sockets', | field = 'sockets', | ||
type = 'Integer', | type = 'Integer', | ||
}, | }, | ||
item_level = { | item_level = { | ||
Line 61: | Line 57: | ||
rarity = { | rarity = { | ||
field = 'rarity', | field = 'rarity', | ||
type = ' | type = 'Page', | ||
}, | }, | ||
reward = { | reward = { | ||
Line 87: | Line 83: | ||
reward = { | reward = { | ||
field = 'reward', | field = 'reward', | ||
type = ' | type = 'Page', | ||
}, | }, | ||
npc = { | npc = { |
Revision as of 17:19, 28 April 2018
Module for handling quest reward related data.
Subpages
The above documentation is transcluded from Module:Quest reward/doc.
Editors can experiment in this module's sandbox and testcases pages.
Subpages of this module.
Editors can experiment in this module's sandbox and testcases pages.
Subpages of this module.
--
-- 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',
},
item_level = {
field = 'item_level',
type = 'Integer',
},
rarity = {
field = 'rarity',
type = 'Page',
},
reward = {
field = 'reward',
type = 'String',
},
},
}
tables.vendor_rewards = {
table = 'vendor_rewards',
fields = {
quest = {
field = 'quest',
type = 'String',
},
quest_id = {
field = 'quest_id',
type = 'Integer',
},
act = {
field = 'act',
type = 'Integer',
},
reward = {
field = 'reward',
type = 'Page',
},
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