Module:Items: Difference between revisions

2,263 bytes added ,  21 September 2020
Added getCreationTable
(Added links to tier column in potion table)
(Added getCreationTable)
Line 109: Line 109:


   result = result..'\r\n|}'
   result = result..'\r\n|}'
  return result
end
function p.getCreationTable(frame)
  local itemName = frame.args ~= nil and frame.args[1] or frame
  local item = p.getItem(itemName)
  if item == nil then
    return "ERROR: No item named "..itemName.." exists in the data module"
  end
  local skill = ''
  local time = 0
  local lvl = 0
  local xp = 0
  local qty = 0
  local req = {}
  --First figure out what skill is used to make this...
  if item.smithingLevel ~= nil then
    skill = 'Smithing'
    lvl = item.smithingLevel
    xp = item.smithingXP
    req = item.smithReq
    qty = item.smithingQty
    time = 2
  elseif item.craftingLevel ~= nil then
    skill = 'Crafting'
    lvl = item.craftingLevel
    xp = item.craftingXP
    req = item.craftReq
    qty = item.craftQty
    time = 3
  elseif item.runecraftingLevel ~= nil then
    skill = 'Runecrafting'
    lvl = item.runecraftingLevel
    xp = item.runecraftingXP
    req = item.runecraftReq
    qty = item.runecraftQty
    time = 2
  elseif item.fletchingLevel ~= nil then
    skill = 'Fletching'
    lvl = item.fletchingLevel
    xp = item.fletchingXP
    req = item.fletchReq
    qty = item.fletchQty
    time = 2
  else
    return "Failed to find creation requirements for this (Possibly the module isn't properly updated for this skill)"
  end
  if qty == nil then qty = 1 end
  local result = '{|class="wikitable"'
  result = result..'\r\n!colspan="2"|Item Creation\r\n|-'
  result = result..'\r\n!style="text-align: right;"|Requirements'
  result = result..'||'..Icons.Icon({skill, type="skill", notext="true"}).."'''"..lvl.."'''"
  result = result..'\r\n!style="text-align: right;"|Materials||'
  for i, mat in pairs(req) do
    if i > 1 then result = result..'<br/>' end
    local matItem = p.getItemByID(mat.id)
    if matItem == nil then
      result = result..mat.qty..'x ?????'
    else
      result = result..Icons.Icon({matItem.name, type='item', qty=mat.qty})
    end
  end
  result = result..'\r\n!style="text-align:right;"|Base Quantity'
  result = result..'||'..qty
  result = result..'\r\n!style="text-align:right;"|Base Experience'
  result = result..'||'..xp
  result = result..'\r\n!style="text-align:right;"|Base Creation Time'
  result = result..'||'..time..' seconds'
  result = result..'\r\n|}'
   return result
   return result
end
end


return p
return p