Module:Skills/Artisan

From Melvor Idle
< Module:Skills
Revision as of 19:09, 17 March 2021 by Falterfire (talk | contribs) (Created page with p.getCookedItemsTable)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Documentation for this module may be created at Module:Skills/Artisan/doc

--Splitting some functions into here to avoid bloating a single file
--Contains function for skills that consume resources (ie smithing, cooking, herblore, etc.)
local p = {}

local SkillData = mw.loadData('Module:Skills/data')
local Constants = mw.loadData('Module:Constants/data')

local Shared = require('Module:Shared')
local Items = require('Module:Items')
local Icons = require('Module:Icons')

function p.getCookedItemsTable(frame)
  local result = '{| class="wikitable sortable stickyHeader"'
  result = result..'\r\n|- class="headerRow-0"'
  result = result..'\r\n!colspan="2"|Cooked Item!!'..Icons.Icon({'Cooking', type='skill', notext=true})..' Level'
  result = result..'!!XP!!Healing!!Value!!Ingredients'

  local itemArray = Items.getItems(function(item) return item.cookingID ~= nil end)
  table.sort(itemArray, function(a, b) return a.cookingLevel < b.cookingLevel end)

  for i, item in Shared.skpairs(itemArray) do
    local cookedItem = Items.getItemByID(item.cookedItemID)
    result = result..'\r\n|-'
    result = result..'\r\n|'..Icons.Icon({cookedItem.name, type='item', notext='true', size='50'})..'||[['..cookedItem.name..']]'
    result = result..'||style="text-align:right"|'..item.cookingLevel
    result = result..'||style="text-align:right"|'..item.cookingXP
    result = result..'||style="text-align:right" data-sort-value="'..cookedItem.healsFor..'"|'..Icons.Icon({"Hitpoints", type="skill", notext=true})..' '..(cookedItem.healsFor * 10)
    result = result..'||style="text-align:right" data-sort-value="'..cookedItem.sellsFor..'"|'..Icons.GP(cookedItem.sellsFor)
    result = result..'||'..Icons.Icon({item.name, type='item', qty = 1})
  end

  result = result..'\r\n|}'
  return result
end

return p