Module:Items: Difference between revisions

1,670 bytes added ,  29 September 2020
Added function to show extra text for some item skillboxes
(Added 'No Description' as a result if an item does not have a description)
(Added function to show extra text for some item skillboxes)
Line 45: Line 45:
   local result = 'local specialFishWt = '..totalWt..'\r\n'
   local result = 'local specialFishWt = '..totalWt..'\r\n'
   result = result..'local specialFishLoot = {'..table.concat(lootArray, ', ')..'}'
   result = result..'local specialFishLoot = {'..table.concat(lootArray, ', ')..'}'
  return result
end
function p.getSpecialAttackByID(ID)
  local result = Shared.clone(ItemData.SpecialAttacks[ID + 1])
  if result ~= nil then
    result.id = ID
  end
   return result
   return result
end
end
Line 335: Line 343:


   return result
   return result
end
function p._getOtherItemBoxText(item)
  result = ''
  --For equipment, show the slot they go in
  if item.equipmentSlot ~= nil then
    for slotName, i in Shared.skpairs(Constants.equipmentSlot) do
      if i == item.equipmentSlot then
        result = result..'\r\n|-\r\n|Equipment Slot: '..slotName
        break
      end
    end
  end
  --For weapons with a special attack, show the details
  if item.hasSpecialAttack then
    local spAtt = p.getSpecialAttackByID(item.specialAttackID)
    result = result..'\r\n|-\r\n|Special Attack:'
    result = result..'\r\n* '..spAtt.chance..'% chance for '..spAtt.name..':'
    result = result..'\r\n** '..spAtt.description
  end
  --For potions, show the number of charges
  if item.potionCharges ~= nil then
    result = result..'\r\n|-\r\n|Charges: '..item.potionCharges
  end
  --For food, show how much it heals for
  if item.healsFor ~= nil then
    result = result..'\r\n|-\r\n|Heals for: '..Icons.Icon({"Hitpoints", type="skill", notext="true"})..' '..(item.healsFor * 10)
  end
  return result
end
function p.getOtherItemBoxText(frame)
  local itemName = frame.args ~= nil and frame.args[1] or frame
  local item = p.getItem(itemName)
  local asList = false
  if frame.args ~= nil then
    asList = frame.args.asList ~= nil and frame.args.asList ~= '' and frame.args.asList ~= 'false'
  end
  if item == nil then
    return "ERROR: No item named "..itemName.." exists in the data module"
  end
  return p._getOtherItemBoxText(item, asList)
end
end