Anonymous

Module:Items/SourceTables: Difference between revisions

From Melvor Idle
moving getOtherItemBoxText back over
(Removing p.getEquipmentSlotName since that belongs over in the base Items module.)
(moving getOtherItemBoxText back over)
Line 243: Line 243:
    
    
   return p._getCreationTable(item)
   return p._getCreationTable(item)
end
function p._getOtherItemBoxText(item)
  result = ''
  --For equipment, show the slot they go in
  if item.equipmentSlot ~= nil then
    result = result..'\r\n|-\r\n|Equipment Slot: '..Items.getEquipmentSlotName(item.equipmentSlot)
  end
  --For weapons with a special attack, show the details
  if item.hasSpecialAttack then
    local spAtt = Items.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
  --For Prayer Points, show how many you get
  if item.prayerPoints ~= nil then
    result = result..'\r\n|-\r\n|'..Icons.Icon({'Prayer', type='skill'})..' Points: '..item.prayerPoints
  end
  return result
end
function p.getOtherItemBoxText(frame)
  local itemName = frame.args ~= nil and frame.args[1] or frame
  local item = Items.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