572
edits
No edit summary |
No edit summary |
||
Line 3: | Line 3: | ||
local GameData = require('Module:GameData') | local GameData = require('Module:GameData') | ||
local p = {} | |||
-- Returns the namespace name (eventually we should use an icon) | |||
function p.PLACEHOLDER_NAMESPACE_ICON(namespace) | |||
-- Returns the namespace name (eventually we should use an icon | |||
function | |||
local namespaces = { | local namespaces = { | ||
melvorD = 'Demo', | melvorD = 'Demo', | ||
Line 17: | Line 14: | ||
return namespaces[namespace] | return namespaces[namespace] | ||
end | end | ||
-- Returns the recipe for the item of a desired skill. | -- Returns the recipe for the item of a desired skill. | ||
function | -- Unfortunately Module:Items/SourceTables.getItemSources does not provide parseable data so we instead use this quick function | ||
function p._FindItemRecipes(itemid, skill) | |||
-- No skill? No recipes | -- No skill? No recipes | ||
Line 76: | Line 70: | ||
end | end | ||
-- Returns a list of all the Township resources | -- Returns a list of all the Township resources | ||
function | function p._ResourcesData() | ||
-- Get a sorted list of all the resources | -- Get a sorted list of all the resources | ||
Line 94: | Line 87: | ||
['melvorF:Ore'] = {_icon = {'Iron Ore', type='rock'}, _skill = 'melvorD:Mining'}, | ['melvorF:Ore'] = {_icon = {'Iron Ore', type='rock'}, _skill = 'melvorD:Mining'}, | ||
['melvorF:Coal'] = {_icon = {'Coal', type='resource'}, _skill = 'melvorD:Mining'}, | ['melvorF:Coal'] = {_icon = {'Coal', type='resource'}, _skill = 'melvorD:Mining'}, | ||
['melvorF:Bar'] = {_icon = {'Iron Bar', type='item'}, _skill = 'melvorD: | ['melvorF:Bar'] = {_icon = {'Iron Bar', type='item'}, _skill = 'melvorD:Smithing'}, | ||
['melvorF:Herbs'] = {_icon = {'Garum Herb', type='item'}, _skill = 'melvorD:Farming'}, | ['melvorF:Herbs'] = {_icon = {'Garum Herb', type='item'}, _skill = 'melvorD:Farming'}, | ||
['melvorF:Rune_Essence'] = {_icon = {'Rune Essence', type='item'}, _skill = 'melvorD:Mining'}, | ['melvorF:Rune_Essence'] = {_icon = {'Rune Essence', type='item'}, _skill = 'melvorD:Mining'}, | ||
Line 113: | Line 106: | ||
-- Returns a list of all the Township resources along with the Trader's trade ratios | -- Returns a list of all the Township resources along with the Trader's trade ratios | ||
function | function p._TraderData() | ||
-- Get the list of resources | -- Get the list of resources | ||
local resources = | local resources = p._ResourcesData() | ||
-- Get the list of tradeable items | -- Get the list of tradeable items | ||
Line 213: | Line 206: | ||
-- Builds the table of trader items | -- Builds the table of trader items | ||
function | function p.getTraderTable(frame) | ||
-- Get the resources data with associated trader data | -- Get the resources data with associated trader data | ||
local resources = | local resources = p._TraderData() | ||
-- Build the text | -- Build the text | ||
Line 253: | Line 246: | ||
} | } | ||
local skill = skill_overrides[item.id] or resource._skill | local skill = skill_overrides[item.id] or resource._skill | ||
local | local skill_namespace, skill_localid = GameData.getLocalID(skill or '') | ||
-- Check for upgraded Crafting items and downgrade them so we can display the crafting level for the base item | -- Check for upgraded Crafting items and downgrade them so we can display the crafting level for the base item | ||
Line 263: | Line 256: | ||
-- Find the recipe's level | -- Find the recipe's level | ||
local recipes = | local recipes = p._FindItemRecipes(lookup_id, skill) | ||
if #recipes == 1 then | if #recipes == 1 then | ||
required_level = recipes[1].level | required_level = recipes[1].level | ||
Line 275: | Line 268: | ||
table.insert(ret_resource, '\r\n|style="text-align:left"|'..Icons.Icon({item.name, type='item', noicon=true})) | table.insert(ret_resource, '\r\n|style="text-align:left"|'..Icons.Icon({item.name, type='item', noicon=true})) | ||
-- DLC | -- DLC | ||
table.insert(ret_resource, '\r\n|style="text-align:center"|'.. | local item_namespace, item_localid = GameData.getLocalID(item.id) | ||
table.insert(ret_resource, '\r\n|style="text-align:center"|'..p.PLACEHOLDER_NAMESPACE_ICON(item_namespace)) | |||
-- Level | -- Level | ||
if required_level == nil then | if required_level == nil then | ||
Line 281: | Line 275: | ||
table.insert(ret_resource, '\r\n|style="text-align:center" data-sort-value="0"|N/A') | table.insert(ret_resource, '\r\n|style="text-align:center" data-sort-value="0"|N/A') | ||
else | else | ||
table.insert(ret_resource, '\r\n|style="text-align:center" data-sort-value="' .. required_level .. '"|'..Icons.Icon({ | table.insert(ret_resource, '\r\n|style="text-align:center" data-sort-value="' .. required_level .. '"|'..Icons.Icon({skill_localid, type="skill", notext=true})..' '..required_level) | ||
end | end | ||
-- Give To | -- Give To | ||
Line 306: | Line 300: | ||
return table.concat(ret) | return table.concat(ret) | ||
end | end | ||
return p | return p |
edits