Anonymous

Module:Skills/Gathering: Difference between revisions

From Melvor Idle
Add slim farming table variant
m (Resize icons)
(Add slim farming table variant)
Line 777: Line 777:
--:tag('td'):wikitext(ItemSourceTables._getItemSources(seedItem))
--:tag('td'):wikitext(ItemSourceTables._getItemSources(seedItem))
--   :css('text-align', 'left')
--   :css('text-align', 'left')
:done()
end
end
return tostring(tbl:done())
end
function p._getSlimFarmingTable(realmID, category)
local category = GameData.getEntityByName(SkillData.Farming.categories, categoryName)
if category == nil then
return Shared.printError('Invalid farming category. Please choose Allotments, Herbs, Trees or Special')
end
local seedList = GameData.getEntities(SkillData.Farming.recipes,
function(recipe)
return recipe.categoryID == category.id and Skills.getRecipeRealm(recipe) == realmID
end)
if Shared.tableIsEmpty(seedList) then
return ''
end
local skillID = 'Farming'
local tbl = mw.html.create()
local html = tbl:tag("table")
        :addClass("wikitable sortable stickyHeader")
    :tag('tr'):addClass("headerRow-0")
    :tag('th'):wikitext(Icons.Icon({'Farming', type='skill', notext=true}) .. '<br>Level')
        :tag('th'):attr("colspan", 2):wikitext("Seeds")
:tag('th'):attr("colspan", 2):wikitext("Produce")
        :tag('th'):wikitext('[[DLC]]')
table.sort(seedList, function(a, b) return Skills.standardRecipeSort(skillID, a, b) end)
for i, seed in ipairs(seedList) do
local seedItem = Items.getItemByID(seed.seedCost.id)
local productItem = Items.getItemByID(seed.productId)
if seedItem ~= nil and productItem ~= nil then
local level = Skills.getRecipeLevel(skillID, seed)
html =
html:tag('tr')
:tag('td'):wikitext(level)
      :css('text-align', 'center')
:tag('td'):wikitext(Icons.Icon({seedItem.name, type='item', notext=true}))
:tag('td'):wikitext('[[' .. seedItem.name .. ']]')
:tag('td'):wikitext(Icons.Icon({productItem.name, type='item', notext=true}))
:tag('td'):wikitext('[[' .. productItem.name .. ']]')
:tag('td'):wikitext(Icons.getExpansionIcon(seedItem.id))
  :css('text-align', 'center')
  :attr('data-sort-value', Icons.getExpansionID(seedItem.id))
:done()
:done()
end
end
Line 787: Line 837:
local args = frame.args ~= nil and frame.args or frame
local args = frame.args ~= nil and frame.args or frame
local realmName = args.realm
local realmName = args.realm
local slim = args.slim == 'true' or args.slim == 'True'
local realm = Skills.getRealmFromName(realmName)
local realm = Skills.getRealmFromName(realmName)
if realm == nil then
if realm == nil then
Line 793: Line 844:
local category = args[1]
local category = args[1]


return p._getFarmingTable(realm.id, category)
if slim == true then
return p._getSlimFarmingTable(realm.id, category)
else
return p._getFarmingTable(realm.id, category)
end
end
end


2,875

edits