Anonymous

Module:Items: Difference between revisions

From Melvor Idle
1,275 bytes added ,  15 December 2020
Added new Passive Items category
(Moving getEquipmentTable over to Module:Items/ComparisonTables)
(Added new Passive Items category)
(8 intermediate revisions by the same user not shown)
Line 12: Line 12:


local Shared = require('Module:Shared')
local Shared = require('Module:Shared')
local Magic = require('Module:Magic')
local Areas = require('Module:CombatAreas')
local Icons = require('Module:Icons')
local Icons = require('Module:Icons')


local EasterEggs = {'Amulet of Calculated Promotion', 'Clue Chasers Insignia', '8', 'Lemon'}
p.EasterEggs = {'Amulet of Calculated Promotion', 'Clue Chasers Insignia', '8', 'Lemon'}
local OtherShopItems = {'Cooking Gloves', 'Mining Gloves', 'Gem Gloves', 'Smithing Gloves', 'Thieving Gloves'}
p.OtherShopItems = {'Cooking Gloves', 'Mining Gloves', 'Gem Gloves', 'Smithing Gloves', 'Thieving Gloves'}
--This is hardcoded, so there's no easy way to scrape it. Hopefully it doesn't change
--This is hardcoded, so there's no easy way to scrape it. Hopefully it doesn't change
p.GemTable = {["Topaz"] = {name = 'Topaz', id = 128, chance = 50},  
p.GemTable = {["Topaz"] = {name = 'Topaz', id = 128, chance = 50},  
Line 25: Line 23:
                   ["Diamond"] = {name = "Diamond", id = 132, chance = 5}}
                   ["Diamond"] = {name = "Diamond", id = 132, chance = 5}}
--The base chance to receive a gem while mining
--The base chance to receive a gem while mining
local GemChance = .01
p.GemChance = .01
--The number of different fishing junk items
--The number of different fishing junk items
local junkCount = 8
p.junkCount = 8
--Items (aside from bars & gems) which can be created via Alt Magic
--Items (aside from bars & gems) which can be created via Alt Magic
local AltMagicProducts = {'Rune Essence', 'Bones', 'Holy Dust'}
local AltMagicProducts = {'Rune Essence', 'Bones', 'Holy Dust'}
Line 252: Line 250:
   if item.category ~= nil then result = result..'[[Category:'..item.category..']]' end
   if item.category ~= nil then result = result..'[[Category:'..item.category..']]' end
   if item.type ~= nil then result = result..'[[Category:'..item.type..']]' end
   if item.type ~= nil then result = result..'[[Category:'..item.type..']]' end
  if item.tier ~= nil then result = result..'[[Category:'..Shared.titleCase(item.tier)..' '..item.type..']]' end
  if item.hasSpecialAttack then result = result..'[[Category:Items With Special Attacks]]' end
  if item.isPassiveItem then result = result..'[[Category:Passive Items]]' end
   return result
   return result
end
end
Line 321: Line 322:
   end
   end
   result = result..'\r\n|}'
   result = result..'\r\n|}'
  return result
end
function p.getSpecialAttackTable(frame)
  local spAttTable = {}
 
  for i, item in Shared.skpairs(ItemData.Items) do
    if item.hasSpecialAttack then
      if spAttTable[item.specialAttackID] == nil then spAttTable[item.specialAttackID] = {sortName=item.name, Icons = {}} end
      table.insert(spAttTable[item.specialAttackID].Icons, Icons.Icon({item.name, type='item'}))
    end
  end 
  local result = '{|class="wikitable sortable stickyHeader"'
  result = result..'\r\n|-class="headerRow-0"'
  result = result..'\r\n!style="min-width:180px"|Weapon(s)!!Name!!Chance!!Effect'
  for i, spAttData in Shared.skpairs(spAttTable) do
    local spAtt = p.getSpecialAttackByID(i)
    table.sort(spAttData.Icons, function(a, b) return a < b end)
    result = result..'\r\n|-'
    result = result..'\r\n|data-sort-value="'..spAttData.sortName..'"|'..table.concat(spAttData.Icons, '<br/>')
    result = result..'||'..spAtt.name..'||data-sort-value="'..spAtt.chance..'"|'..spAtt.chance..'%'
    result = result..'||'..spAtt.description
  end
  result = result..'\r\n|}'
   return result
   return result
end
end


return p
return p