Anonymous

Module:Skills: Difference between revisions

From Melvor Idle
1,943 bytes added ,  17 October 2020
Added functions for building farming tables
(Fixed misordering on some Mastery Unlock tables)
(Added functions for building farming tables)
Line 64: Line 64:
   result = result..'\r\n|}'
   result = result..'\r\n|}'
   return result
   return result
end
function p._getFarmingTable(category)
  local seedList = {}
  if category == 'Allotment' or category == 'Herb' or category == 'Tree' then
    seedList = Items.getItems(function(item) return item.tier == category end)
  else
    return 'ERROR: Invalid farming category. Please choose Allotment, Herb, or Tree'
  end
  local result = '{|class="wikitable sortable stickyHeader"'
  result = result..'\r\n|- class=headerRow-0"'
  result = result..'\r\n!colspan=2|Seeds!!'..Icons.Icon({'Farming', type='skill', notext=true})..' Level'
  result = result..'!!XP!!Growth Time!!Seed Value'
  if category == 'Allotment' then
    result = result..'!!colspan="2"|Crop!!Crop Healing!!Crop Value'
  elseif category == 'Herb' then
    result = result..'!!colspan="2"|Herb!!Herb Value'
  elseif category == 'Tree' then
    result = result..'!!colspan="2"|Logs!!Log Value'
  end
  result = result..'!!Seed Sources'
 
  table.sort(seedList, function(a, b) return a.farmingLevel < b.farmingLevel end)
  for i, seed in pairs(seedList) do
    result = result..'\r\n|-'
    result = result..'\r\n|'..Icons.Icon({seed.name, type='item', size='50', notext=true})..'||[['..seed.name..']]'
    result = result..'||'..seed.farmingLevel..'||'..seed.farmingXP..'||'..Shared.timeString(seed.timeToGrow)
    result = result..'||'..Icons.GP(seed.sellsFor)
    local crop = Items.getItemByID(seed.grownItemID)
    result = result..'||'..Icons.Icon({crop.name, type='item', size='50', notext=true})..'||[['..crop.name..']]'
    if category == 'Allotment' then
      result = result..'||'..Icons.Icon({'Hitpoints', type='skill', notext=true})..' '..crop.healsFor
    end
    result = result..'||'..Icons.GP(crop.sellsFor)
    result = result..'||'..Items._getItemSources(seed)
  end
  result = result..'\r\n|}'
  return result
end
function p.getFarmingTable(frame)
  local category = frame.args ~= nil and frame.args[1] or frame
  return p._getFarmingTable(category)
end
end


return p
return p