Anonymous

Module:Items: Difference between revisions

From Melvor Idle
1,983 bytes added ,  30 September 2020
Added alt magic tables to the item sources thing
(Added 'Alt Magic' header to Superheat section)
(Added alt magic tables to the item sources thing)
Line 301: Line 301:
       table.insert(tables, p.buildCreationTable(skill, lvl, xp, req, qty, time))
       table.insert(tables, p.buildCreationTable(skill, lvl, xp, req, qty, time))
     end
     end
  end
  --A couple special exceptions for Alt Magic
  --Not Gems or Bars though since those have their own separate thing
  if item.name == 'Rune Essence' then
    table.insert(tables, p.buildAltMagicTable('Just Learning'))
  elseif item.name == 'Bones' then
    table.insert(tables, p.buildAltMagicTable('Bone Offering')) 
  elseif item.name == 'Holy Dust' then
    table.insert(tables, p.buildAltMagicTable('Blessed Offering'))
   end
   end


Line 308: Line 317:
     return table.concat(tables, '\r\n')
     return table.concat(tables, '\r\n')
   end
   end
end
function p.buildAltMagicTable(spellName)
  local spell = Magic.getSpell(spellName, 'AltMagic')
  local result = '{|class="wikitable"\r\n|-'
  result = result..'\r\n!colspan="2"|'..Icons.Icon({spell.name, type='spell'})
  -- 1 means select any item. 0 would mean Superheat, but that's handled elsewhere
  -- -1 means no item is needed, so hide this section
  if spell.selectItem == 1 then
    result = result..'\r\n|-\r\n!style="text-align:right;"|Requirements'
    result = result..'\r\n|1 of any item'
  end
  --Add runes
  result = result..'\r\n|-\r\n!style="text-align:right;"|Runes\r\n|'
  for i, req in pairs(spell.runesRequired) do
    local rune = p.getItemByID(req.id)
    if i > 1 then result = result..', ' end
    result = result..Icons.Icon({rune.name, type='item', notext=true, qty=req.qty})
  end
  if spell.runesRequiredAlt ~= nil and Shared.tableCount(spell.runesRequired) ~= Shared.tableCount(spell.runesRequiredAlt) then
    result = result.."<br/>'''OR'''<br/>"
    for i, req in pairs(spell.runesRequiredAlt) do
      local rune = p.getItemByID(req.id)
      if i > 1 then result = result..', ' end
      result = result..Icons.Icon({rune.name, type='item', notext=true, qty=req.qty})
    end
  end
  --Now just need the output quantity, xp, and casting time (which is always 2)
  result = result..'\r\n|-\r\n!style="text-align:right;"|Base Quantity\r\n|'..spell.convertToQty
  result = result..'\r\n|-\r\n!style="text-align:right;"|Base XP\r\n|'..spell.magicXP
  result = result..'\r\n|-\r\n!style="text-align:right;"|Cast Time\r\n|2s'
  result = result..'\r\n|}'
  return result
end
end


Line 989: Line 1,032:
   if Shared.tableCount(dropRows) == 0 then return '' end
   if Shared.tableCount(dropRows) == 0 then return '' end


   table.sort(dropRows, function(a, b) return a.qty * a.chance > b.qty * b.chance end)
   table.sort(dropRows, function(a, b) return a.chance > b.chance end)
   for i, data in pairs(dropRows) do
   for i, data in pairs(dropRows) do
     result = result..buildRow(data.source, data.type, data.minqty, data.qty, data.chance)
     result = result..buildRow(data.source, data.type, data.minqty, data.qty, data.chance)
Line 1,016: Line 1,059:
     if item.buysFor > 0 then table.insert(cost, Icons.GP(item.buysFor)) end
     if item.buysFor > 0 then table.insert(cost, Icons.GP(item.buysFor)) end
   elseif item.slayerCost ~= nil then
   elseif item.slayerCost ~= nil then
     table.insert(cost, Icons.Icon({'Slayer Coins', qty=item.slayerCost, notext='true'}))
     table.insert(cost, Icons.SC(item.slayerCost))
   elseif GloveTable[item.name] ~= nil then
   elseif GloveTable[item.name] ~= nil then
     table.insert(cost, Icons.GP(GloveTable[item.name].cost))
     table.insert(cost, Icons.GP(GloveTable[item.name].cost))