Module:GenericData
Overview
Provides access to generic/miscellaneous data from Data:GenericData.json
Functions
get_objective_param
Provides access to "ObjectiveParams" data.
Parameters
- key - key to access
Examples
{{#invoke:GenericData|get_objective_param|GoldPerOrb}}
40
get_rejuv_param
Provides access to "RejuvParams" data.
Parameters
- key - key to access
- midboss_deaths - (OPTIONAL) list index to access that represents how many times midboss has died, if the provided key's value is a list
Examples
{{#invoke:GenericData|get_rejuv_param|RejuvinatorExpirationWarningTiming}}
30
{{#invoke:GenericData|get_rejuv_param|TrooperHealthMult|3}}
1.9
get_tiered_item_price
Provides access to "ItemPricePerTier" data.
Parameters
- tier - list index to access that represents the tier of the item
Examples
{{#invoke:GenericData|get_tiered_item_price|5}}
6200
local generics_data = mw.loadJsonData("Data:GenericData.json")
local p = {}
function p.get_objective_param(frame)
local key = frame.args[1]
if key == nil then return "'key' parameter must be provided" end
objective_params = generics_data['ObjectiveParams']
objective_param = objective_params[key]
if objective_param == nil then
return "'key':" .. key .. " is not in ObjectiveParams"
end
return objective_param
end
function p.get_rejuv_param(frame)
local key = frame.args[1]
local midboss_deaths = frame.args[2]
if key == nil then return "'key' parameter must be provided" end
if midboss_deaths ~= nil and tonumber(midboss_deaths) == nil then
return "'midboss_deaths' parameter must be an integer"
end
-- Access the key
rejuv_params = generics_data['RejuvParams']
rejuv_param = rejuv_params[key]
-- Ensure the key is in the data
if rejuv_param == nil then
return "'key':" .. key .. " is not in RejuvParams"
end
-- If its a non-container, return it
if (type(rejuv_param) == 'number' or
type(rejuv_param) == 'string' or
type(rejuv_param) == 'boolean') then
return rejuv_param
end
-- Ensure an midboss_deaths is provided
if midboss_deaths == nil then return "'key':" .. key .. "'s value is an array, so the 'midboss_deaths' parameter must be provided" end
midboss_deaths = tonumber(midboss_deaths)
-- Retrieve the midboss_deaths'th element
for i, elem in ipairs(rejuv_param) do
if i == midboss_deaths then
return elem
end
end
return "'key':" .. key .. "'s array value did not contain " .. midboss_deaths .. " elements"
end
function p.get_tiered_item_price(frame)
local tier = frame.args[1]
if tier == nil then return "'tier' parameter must be provided" end
tier = tonumber(tier)
-- Retrieve the tier'th element
for i, elem in ipairs(generics_data["ItemPricePerTier"]) do
if i == tier then
return elem
end
end
return "ItemPricePerTier does not have " .. tier .. " tiers"
end
return p