572
edits
m (Gau Cho moved page Module:GauTest/Township to Module:Township without leaving a redirect) |
No edit summary |
||
Line 2: | Line 2: | ||
local Icons = require('Module:Icons') | local Icons = require('Module:Icons') | ||
local GameData = require('Module:GameData') | local GameData = require('Module:GameData') | ||
local resource_data = { | |||
['melvorF:GP'] = {icon = {'Coins'}, skill = nil}, | |||
['melvorF:Food'] = {icon = {'Raw Beef', type='item'}, skill = 'melvorD:Cooking'}, | |||
['melvorF:Wood'] = {icon = {'Wood', type='resource'}, skill = 'melvorD:Woodcutting'}, | |||
['melvorF:Stone'] = {icon = {'Stone', type='resource'}, skill = 'melvorD:Mining'}, | |||
['melvorF:Ore'] = {icon = {'Iron', type='rock'}, skill = 'melvorD:Mining'}, | |||
['melvorF:Coal'] = {icon = {'Coal', type='resource'}, skill = 'melvorD:Mining'}, | |||
['melvorF:Bar'] = {icon = {'Iron Bar', type='item'}, skill = 'melvorD:Smithing'}, | |||
['melvorF:Herbs'] = {icon = {'Garum Herb', type='item'}, skill = 'melvorD:Farming'}, | |||
['melvorF:Rune_Essence'] = {icon = {'Rune Essence', type='item'}, skill = 'melvorD:Mining'}, | |||
['melvorF:Leather'] = {icon = {'Leather', type='item'}, skill = nil}, | |||
['melvorF:Potions'] = {icon = {'Potion', type='resource'}, skill = 'melvorD:Herblore'}, | |||
['melvorF:Planks'] = {icon = {'Planks', type='resource'}, skill = 'melvorD:Woodcutting'}, | |||
['melvorF:Clothing'] = {icon = {'Leather Body', type='item'}, skill = 'melvorD:Crafting'} | |||
} | |||
local p = {} | local p = {} | ||
Line 77: | Line 94: | ||
local resources = GameData.sortByOrderTable(Township.resources, Township.resourceDisplayOrder[1].ids) | local resources = GameData.sortByOrderTable(Township.resources, Township.resourceDisplayOrder[1].ids) | ||
resources = Shared.clone(resources) | resources = Shared.clone(resources) | ||
return resources | return resources | ||
Line 152: | Line 145: | ||
end | end | ||
local | local traderMatchesList = { | ||
['melvorF:GP'] = {traderMatches = matchNone}, | ['melvorF:GP'] = {traderMatches = matchNone}, | ||
['melvorF:Food'] = {traderMatches = matchFood}, | ['melvorF:Food'] = {traderMatches = matchFood}, | ||
Line 169: | Line 162: | ||
for _, resource in ipairs(resources) do | for _, resource in ipairs(resources) do | ||
resource.itemConversions = Shared.clone(GameData.getEntities('items', | resource.itemConversions = Shared.clone(GameData.getEntities('items', traderMatchesList[resource.id].traderMatches)) | ||
end | end | ||
Line 206: | Line 199: | ||
-- Builds the table of trader items | -- Builds the table of trader items | ||
function p. | function p.GetTraderTable(frame) | ||
-- Get the resources data with associated trader data | -- Get the resources data with associated trader data | ||
local resources = p._TraderData() | local resources = p._TraderData() | ||
Line 245: | Line 238: | ||
['melvorF:Apple'] = 'melvorD:Farming', | ['melvorF:Apple'] = 'melvorD:Farming', | ||
} | } | ||
local skill = skill_overrides[item.id] or resource. | local skill = skill_overrides[item.id] or p._GetResourceSkill(resource.id) | ||
local skill_namespace, skill_localid = GameData.getLocalID(skill or '') | local skill_namespace, skill_localid = GameData.getLocalID(skill or '') | ||
Line 280: | Line 273: | ||
table.insert(ret_resource, '\r\n|style="text-align:center" data-sort-value="' .. item.toTownship .. '"|'..Icons.Icon({item.name, type='item', notext=true})..' '..Shared.formatnum(item.toTownship)) | table.insert(ret_resource, '\r\n|style="text-align:center" data-sort-value="' .. item.toTownship .. '"|'..Icons.Icon({item.name, type='item', notext=true})..' '..Shared.formatnum(item.toTownship)) | ||
-- Take From | -- Take From | ||
table.insert(ret_resource, '\r\n|style="text-align:center" data-sort-value="' .. item.fromTownship .. '"|'..Icons.Icon(resource. | table.insert(ret_resource, '\r\n|style="text-align:center" data-sort-value="' .. item.fromTownship .. '"|'..Icons.Icon(p._GetResourceIcon(resource.id))..' '..Shared.formatnum(item.fromTownship)) | ||
-- Value | -- Value | ||
table.insert(ret_resource, '\r\n|style="text-align:center" data-sort-value="' .. item.sellsFor .. '"|'..Icons.GP(item.sellsFor)) | table.insert(ret_resource, '\r\n|style="text-align:center" data-sort-value="' .. item.sellsFor .. '"|'..Icons.GP(item.sellsFor)) | ||
Line 299: | Line 292: | ||
end | end | ||
return table.concat(ret) | return table.concat(ret) | ||
end | |||
-- Gets the icon of a resource | |||
-- e.g. Icons.Icon(_GetResourceIcon('melvorF:Bar')) | |||
function p._GetResourceIcon(id) | |||
local resource_icon = Shared.clone(resource_data[id].icon) | |||
resource_icon.notext = true | |||
resource_icon.nolink = true | |||
return resource_icon | |||
end | |||
-- Gets the associated skill of a resource by id | |||
function p._GetResourceSkill(id) | |||
return resource_data[id].skill | |||
end | |||
-- Gets a Township building by ID, e.g. melvorF:Hunters_Cabin | |||
function p._GetBuildingByID(id) | |||
GameData.getEntityByID(GameData.getSkillData('melvorD:Township').buildings, id) | |||
end | |||
-- Gets a building and prepares all the relevant stats for the building | |||
function p._GetBuildingProfile(id) | |||
local building = p._GetBuildingByID(id) | |||
local resources = p._ResourcesData() | |||
end | end | ||
return p | return p |
edits