Module:InfoboxNPC: Difference between revisions

From August Wiki
Jump to navigation Jump to search
Created page with "local p = {} function p.renderInfobox(frame) local args = frame.args local parent = frame:getParent() if parent then args = parent.args end local html = [[ <table class="infobox no-parenthesis-style infobox-item"> <tr> <th colspan="24" class="infobox-header">]] .. (args.name or "Unknown Monster") .. [[</th> </tr> <tr> <td colspan="24" class="infobox-padding"></td> </tr>]] -- Character Image (cond..."
 
No edit summary
Line 4: Line 4:
     local args = frame.args
     local args = frame.args
     local parent = frame:getParent()
     local parent = frame:getParent()
   
 
     if parent then
     if parent then
         args = parent.args
         args = parent.args
     end
     end
   
 
     local html = [[
     local html = [[
<table class="infobox no-parenthesis-style infobox-item">
<table class="infobox no-parenthesis-style infobox-item">
Line 17: Line 17:
       <td colspan="24" class="infobox-padding"></td>
       <td colspan="24" class="infobox-padding"></td>
     </tr>]]
     </tr>]]
   
 
     -- Character Image (conditional)
     -- Character Image (conditional)
     if args.image and args.image ~= "" then
     if args.image and args.image ~= "" then
         html = html .. [[
         html = html .. [[
     <tr>
     <tr>
       <td colspan="24" class="infobox-image infobox-full-width-content">]] .. "[[File:" .. args.image .. "|32px]]" .. [[</td>
       <td colspan="24" class="infobox-image infobox-full-width-content">]] .. "[[File:" .. args.image .. "|32px]]" ..
                  [[</td>
     </tr>
     </tr>
     <tr>
     <tr>
Line 28: Line 29:
     </tr>]]
     </tr>]]
     end
     end
   
 
     -- Basic Information (conditional for each row)
     -- Basic Information (conditional for each row)
     local hasBasicInfo = false
     local hasBasicInfo = false
   
 
     -- Released
     -- Released
     if args.released and args.released ~= "" then
     if args.released and args.released ~= "" then
Line 41: Line 42:
         hasBasicInfo = true
         hasBasicInfo = true
     end
     end
   
 
     -- Members
     -- Members
     if args.members and args.members ~= "" then
     if args.members and args.members ~= "" then
Line 51: Line 52:
         hasBasicInfo = true
         hasBasicInfo = true
     end
     end
   
 
     -- Combat level
     -- Combat level
     if args.combat_level and args.combat_level ~= "" then
     if args.combat_level and args.combat_level ~= "" then
Line 61: Line 62:
         hasBasicInfo = true
         hasBasicInfo = true
     end
     end
   
 
     -- Size
     -- Size
     if args.size and args.size ~= "" then
     if args.size and args.size ~= "" then
Line 71: Line 72:
         hasBasicInfo = true
         hasBasicInfo = true
     end
     end
   
 
     -- Examine
     -- Examine
     if args.examine and args.examine ~= "" then
     if args.examine and args.examine ~= "" then
Line 81: Line 82:
         hasBasicInfo = true
         hasBasicInfo = true
     end
     end
   
 
     -- League Information
     -- League Information
     if args.league_region and args.league_region ~= "" then
     if args.league_region and args.league_region ~= "" then
Line 91: Line 92:
         hasBasicInfo = true
         hasBasicInfo = true
     end
     end
   
 
     -- Add padding if at least one basic info field was displayed
     -- Add padding if at least one basic info field was displayed
     if hasBasicInfo then
     if hasBasicInfo then
Line 99: Line 100:
     </tr>]]
     </tr>]]
     end
     end
   
 
     -- Check if any combat info fields have values
     -- Check if any combat info fields have values
     local hasCombatInfo = false
     local hasCombatInfo = false
     local combatInfoFields = {"xp_bonus", "max_hit", "aggressive", "poisonous", "attack_style", "attack_speed", "respawn_time"}
     local combatInfoFields = {"xp_bonus", "max_hit", "aggressive", "poisonous", "attack_style", "attack_speed",
   
                              "respawn_time"}
 
     for _, field in ipairs(combatInfoFields) do
     for _, field in ipairs(combatInfoFields) do
         if args[field] and args[field] ~= "" then
         if args[field] and args[field] ~= "" then
Line 110: Line 112:
         end
         end
     end
     end
   
 
     -- Combat Information Section (only if at least one field has a value)
     -- Combat Information Section (only if at least one field has a value)
     if hasCombatInfo then
     if hasCombatInfo then
Line 120: Line 122:
       <td colspan="24" class="infobox-padding"></td>
       <td colspan="24" class="infobox-padding"></td>
     </tr>]]
     </tr>]]
       
 
         -- XP Bonus
         -- XP Bonus
         if args.xp_bonus and args.xp_bonus ~= "" then
         if args.xp_bonus and args.xp_bonus ~= "" then
Line 129: Line 131:
     </tr>]]
     </tr>]]
         end
         end
       
 
         -- Max hit
         -- Max hit
         if args.max_hit and args.max_hit ~= "" then
         if args.max_hit and args.max_hit ~= "" then
Line 138: Line 140:
     </tr>]]
     </tr>]]
         end
         end
       
 
         -- Aggressive
         -- Aggressive
         if args.aggressive and args.aggressive ~= "" then
         if args.aggressive and args.aggressive ~= "" then
Line 147: Line 149:
     </tr>]]
     </tr>]]
         end
         end
       
 
         -- Poisonous
         -- Poisonous
         if args.poisonous and args.poisonous ~= "" then
         if args.poisonous and args.poisonous ~= "" then
Line 156: Line 158:
     </tr>]]
     </tr>]]
         end
         end
       
 
         -- Attack style
         -- Attack style
         if args.attack_style and args.attack_style ~= "" then
         if args.attack_style and args.attack_style ~= "" then
Line 165: Line 167:
     </tr>]]
     </tr>]]
         end
         end
       
 
         -- Attack speed
         -- Attack speed
         if args.attack_speed and args.attack_speed ~= "" then
         if args.attack_speed and args.attack_speed ~= "" then
Line 174: Line 176:
     </tr>]]
     </tr>]]
         end
         end
       
 
         -- Respawn time
         -- Respawn time
         if args.respawn_time and args.respawn_time ~= "" then
         if args.respawn_time and args.respawn_time ~= "" then
Line 183: Line 185:
     </tr>]]
     </tr>]]
         end
         end
       
 
         html = html .. [[
         html = html .. [[
     <tr>
     <tr>
Line 189: Line 191:
     </tr>]]
     </tr>]]
     end
     end
   
 
     -- Check if any slayer info fields have values
     -- Check if any slayer info fields have values
     local hasSlayerInfo = false
     local hasSlayerInfo = false
     local slayerInfoFields = {"slayer_level", "slayer_xp", "slayer_category", "slayer_masters"}
     local slayerInfoFields = {"slayer_level", "slayer_xp", "slayer_category", "slayer_masters"}
   
 
     for _, field in ipairs(slayerInfoFields) do
     for _, field in ipairs(slayerInfoFields) do
         if args[field] and args[field] ~= "" then
         if args[field] and args[field] ~= "" then
Line 200: Line 202:
         end
         end
     end
     end
   
 
     -- Slayer Section (only if at least one field has a value)
     -- Slayer Section (only if at least one field has a value)
     if hasSlayerInfo then
     if hasSlayerInfo then
         local slayerIcon = args.slayer_icon or "Slayer_icon.png"
         local slayerIcon = args.slayer_icon or "Slayer_icon.png"
       
 
         html = html .. [[
         html = html .. [[
     <tr>
     <tr>
Line 212: Line 214:
       <td colspan="24" class="infobox-padding"></td>
       <td colspan="24" class="infobox-padding"></td>
     </tr>]]
     </tr>]]
       
 
         -- Slayer level
         -- Slayer level
         if args.slayer_level and args.slayer_level ~= "" then
         if args.slayer_level and args.slayer_level ~= "" then
Line 221: Line 223:
     </tr>]]
     </tr>]]
         end
         end
       
 
         -- Slayer XP
         -- Slayer XP
         if args.slayer_xp and args.slayer_xp ~= "" then
         if args.slayer_xp and args.slayer_xp ~= "" then
Line 230: Line 232:
     </tr>]]
     </tr>]]
         end
         end
       
 
         -- Category
         -- Category
         if args.slayer_category and args.slayer_category ~= "" then
         if args.slayer_category and args.slayer_category ~= "" then
Line 239: Line 241:
     </tr>]]
     </tr>]]
         end
         end
       
 
         -- Assigned by
         -- Assigned by
         if args.slayer_masters and args.slayer_masters ~= "" then
         if args.slayer_masters and args.slayer_masters ~= "" then
Line 248: Line 250:
     </tr>]]
     </tr>]]
         end
         end
       
 
         html = html .. [[
         html = html .. [[
     <tr>
     <tr>
Line 254: Line 256:
     </tr>]]
     </tr>]]
     end
     end
   
 
     -- Check if any combat stats have values
     -- Check if any combat stats have values
     local hasCombatStats = false
     local hasCombatStats = false
     local combatStatFields = {"hitpoints", "attack", "strength", "defence", "magic", "ranged"}
     local combatStatFields = {"hitpoints", "attack", "strength", "defence", "magic", "ranged"}
   
 
     for _, field in ipairs(combatStatFields) do
     for _, field in ipairs(combatStatFields) do
         if args[field] and args[field] ~= "" then
         if args[field] and args[field] ~= "" then
Line 265: Line 267:
         end
         end
     end
     end
   
 
     -- Combat Stats Section (only if at least one stat has a value)
     -- Combat Stats Section (only if at least one stat has a value)
     if hasCombatStats then
     if hasCombatStats then
Line 275: Line 277:
         local magicIcon = args.magic_icon or "Magic_icon.png"
         local magicIcon = args.magic_icon or "Magic_icon.png"
         local rangedIcon = args.ranged_icon or "Ranged_icon.png"
         local rangedIcon = args.ranged_icon or "Ranged_icon.png"
       
 
         html = html .. [[
         html = html .. [[
     <tr>
     <tr>
Line 303: Line 305:
     </tr>]]
     </tr>]]
     end
     end
   
 
     -- Check if any aggressive stats have values
     -- Check if any aggressive stats have values
     local hasAggressiveStats = false
     local hasAggressiveStats = false
     local aggressiveStatFields = {"attack_bonus", "strength_bonus", "magic_bonus", "magic_damage", "ranged_bonus", "ranged_strength"}
     local aggressiveStatFields = {"attack_bonus", "strength_bonus", "magic_bonus", "magic_damage", "ranged_bonus",
   
                                  "ranged_strength"}
 
     for _, field in ipairs(aggressiveStatFields) do
     for _, field in ipairs(aggressiveStatFields) do
         if args[field] and args[field] ~= "" then
         if args[field] and args[field] ~= "" then
Line 314: Line 317:
         end
         end
     end
     end
   
 
     -- Aggressive stats section (only if at least one stat has a value)
     -- Aggressive stats section (only if at least one stat has a value)
     if hasAggressiveStats then
     if hasAggressiveStats then
Line 323: Line 326:
         local rangedIcon = args.ranged_icon or "Ranged_icon.png"
         local rangedIcon = args.ranged_icon or "Ranged_icon.png"
         local rangedStrengthIcon = args.ranged_strength_icon or "Ranged_Strength_icon.png"
         local rangedStrengthIcon = args.ranged_strength_icon or "Ranged_Strength_icon.png"
       
 
         html = html .. [[
         html = html .. [[
     <tr>
     <tr>
Line 351: Line 354:
     </tr>]]
     </tr>]]
     end
     end
   
 
     -- Check if any melee defence stats have values
     -- Check if any melee defence stats have values
     local hasMeleeDefence = false
     local hasMeleeDefence = false
     local meleeDefenceFields = {"stab_def", "slash_def", "crush_def"}
     local meleeDefenceFields = {"stab_def", "slash_def", "crush_def"}
   
 
     for _, field in ipairs(meleeDefenceFields) do
     for _, field in ipairs(meleeDefenceFields) do
         if args[field] and args[field] ~= "" then
         if args[field] and args[field] ~= "" then
Line 362: Line 365:
         end
         end
     end
     end
   
 
    -- Melee Defence Section (only if at least one defence stat has a value)
    if hasMeleeDefence then
        local defenceIcon = args.defence_icon or "Defence_icon.png"
        local stabIcon = args.stab_icon or "White_dagger.png"
        local slashIcon = args.slash_icon or "White_scimitar.png"
        local crushIcon = args.crush_icon or "White_warhammer.png"
       
        html = html .. [[
    <tr>
      <th colspan="24" class="infobox-subheader">]] .. "[[File:" .. defenceIcon .. "|17px]] Melee defence" .. [[</th>
    </tr>
    <tr>
      <td colspan="24" class="infobox-padding"></td>
    </tr>
    <tr>
      <th colspan="8" class="infobox-nested">]] .. "[[File:" .. stabIcon .. "|21px]]" .. [[</th>
      <th colspan="8" class="infobox-nested">]] .. "[[File:" .. slashIcon .. "|27px]]" .. [[</th>
      <th colspan="8" class="infobox-nested">]] .. "[[File:" .. crushIcon .. "|22px]]" .. [[</th>
    </tr>
    <tr>
      <td colspan="8" class="infobox-nested">]] .. (args.stab_def or "") .. [[</td>
      <td colspan="8" class="infobox-nested">]] .. (args.slash_def or "") .. [[</td>
      <td colspan="8" class="infobox-nested">]] .. (args.crush_def or "") .. [[</td>
    </tr>
    <tr>
      <td colspan="24" class="infobox-padding"></td>
    </tr>]]
    end
   
     -- Check if any magic defence stats have values
     -- Check if any magic defence stats have values
     local hasMagicDefence = false
     local hasMagicDefence = false
     local magicDefenceFields = {"magic_defence", "elemental_weakness"}
     local magicDefenceFields = {"magic_def"}
   
 
     for _, field in ipairs(magicDefenceFields) do
     for _, field in ipairs(magicDefenceFields) do
         if args[field] and args[field] ~= "" then
         if args[field] and args[field] ~= "" then
Line 402: Line 376:
         end
         end
     end
     end
   
 
    -- Magic Defence Section (only if at least one magic defence stat has a value)
    if hasMagicDefence then
        local magicDefenceIcon = args.magic_defence_icon or "Magic_defence_icon.png"
        local magicIcon = args.magic_icon or "Magic_icon.png"
        local elementalWeaknessIcon = args.elemental_weakness_icon or "Pure_essence.png"
       
        html = html .. [[
    <tr>
      <th colspan="24" class="infobox-subheader">]] .. "[[File:" .. magicDefenceIcon .. "|30px]] Magic defence" .. [[</th>
    </tr>
    <tr>
      <td colspan="24" class="infobox-padding"></td>
    </tr>
    <tr>
      <th colspan="12" class="infobox-nested">]] .. "[[File:" .. magicIcon .. "|25px]]" .. [[</th>
      <th colspan="12" class="infobox-nested">]] .. "[[File:" .. elementalWeaknessIcon .. "|29px]]" .. [[</th>
    </tr>
    <tr>
      <td colspan="12" class="infobox-nested">]] .. (args.magic_defence or "") .. [[</td>
      <td colspan="12" class="infobox-nested">]] .. (args.elemental_weakness or "") .. [[</td>
    </tr>
    <tr>
      <td colspan="24" class="infobox-padding"></td>
    </tr>]]
    end
   
     -- Check if any ranged defence stats have values
     -- Check if any ranged defence stats have values
     local hasRangedDefence = false
     local hasRangedDefence = false
     local rangedDefenceFields = {"light_def", "standard_def", "heavy_def"}
     local rangedDefenceFields = {"ranged_def"}
   
 
     for _, field in ipairs(rangedDefenceFields) do
     for _, field in ipairs(rangedDefenceFields) do
         if args[field] and args[field] ~= "" then
         if args[field] and args[field] ~= "" then
Line 439: Line 387:
         end
         end
     end
     end
   
 
    -- Ranged Defence Section (only if at least one ranged defence stat has a value)
     if hasRangedDefence then
     if hasRangedDefence then
         local rangedDefenceIcon = args.ranged_defence_icon or "Ranged_defence_icon.png"
         local rangedDefenceIcon = args.ranged_defence_icon or "Ranged_defence_icon.png"
         local lightIcon = args.light_icon or "Steel_dart.png"
    end
         local standardIcon = args.standard_icon or "Steel_arrow_5.png"
 
         local heavyIcon = args.heavy_icon or "Steel_bolts_5.png"
    if hasMagicDefence then
          
         local magicDefenceIcon = args.magic_defence_icon or "Magic_defence_icon.png"
    end
 
    -- Melee Defence Section (only if at least one defence stat has a value)
    if hasMeleeDefence or hasMagicDefence or hasRangedDefence then -- Check all types of defence.
         local defenceIcon = args.defence_icon or "Defence_icon.png"
         local stabIcon = args.stab_icon or "White_dagger.png"
         local slashIcon = args.slash_icon or "White_scimitar.png"
        local crushIcon = args.crush_icon or "White_warhammer.png"
        local rangedDefenceIcon = args.ranged_defence_icon or "Ranged_defence_icon.png"
        local magicDefenceIcon = args.magic_defence_icon or "Magic_defence_icon.png"
 
         html = html .. [[
         html = html .. [[
     <tr>
     <tr>
      <th colspan="24" class="infobox-subheader">]] .. "[[File:" .. rangedDefenceIcon .. "|28px]] Ranged defence" .. [[</th>
        <th colspan="25" class="infobox-subheader">]] .. "[[File:" .. defenceIcon .. "|17px]] Defence" .. [[</th>
     </tr>
     </tr>
     <tr>
     <tr>
      <td colspan="24" class="infobox-padding"></td>
        <td colspan="25" class="infobox-padding"></td>
     </tr>
     </tr>
     <tr>
     <tr>
      <th colspan="8" class="infobox-nested">]] .. "[[File:" .. lightIcon .. "|20px]]" .. [[</th>
        <th colspan="5" class="infobox-nested">]] .. "[[File:" .. stabIcon .. "|21px]]" .. [[</th>
      <th colspan="8" class="infobox-nested">]] .. "[[File:" .. standardIcon .. "|31px]]" .. [[</th>
        <th colspan="5" class="infobox-nested">]] .. "[[File:" .. slashIcon .. "|27px]]" .. [[</th>
      <th colspan="8" class="infobox-nested">]] .. "[[File:" .. heavyIcon .. "|28px]]" .. [[</th>
        <th colspan="5" class="infobox-nested">]] .. "[[File:" .. crushIcon .. "|22px]]" .. [[</th>
        <th colspan="5" class="infobox-nested">]] .. "[[File:" .. rangedDefenceIcon .. "|22px]]" .. [[</th>
        <th colspan="5" class="infobox-nested">]] .. "[[File:" .. magicDefenceIcon .. "|22px]]" .. [[</th>
     </tr>
     </tr>
     <tr>
     <tr>
      <td colspan="8" class="infobox-nested">]] .. (args.light_def or "") .. [[</td>
        <td colspan="6" class="infobox-nested">]] .. (args.stab_def or "0") .. [[</td>
      <td colspan="8" class="infobox-nested">]] .. (args.standard_def or "") .. [[</td>
        <td colspan="6" class="infobox-nested">]] .. (args.slash_def or "0") .. [[</td>
      <td colspan="8" class="infobox-nested">]] .. (args.heavy_def or "") .. [[</td>
        <td colspan="6" class="infobox-nested">]] .. (args.crush_def or "0") .. [[</td>
        <td colspan="6" class="infobox-nested">]] .. (args.ranged_def or "0") .. [[</td>
        <td colspan="24" class="infobox-nested">]] .. (args.magic_def or "0") .. [[</td>
     </tr>
     </tr>
     <tr>
     <tr>
      <td colspan="24" class="infobox-padding"></td>
        <td colspan="25" class="infobox-padding"></td>
     </tr>]]
     </tr>]]
     end
     end
   
 
     -- Check if any immunity values have been specified
     -- Check if any immunity values have been specified
     local hasImmunities = false
     local hasImmunities = false
     local immunityFields = {"poison_immunity", "venom_immunity", "cannon_immunity", "thrall_immunity"}
     local immunityFields = {"poison_immunity", "venom_immunity", "cannon_immunity", "thrall_immunity"}
   
 
     for _, field in ipairs(immunityFields) do
     for _, field in ipairs(immunityFields) do
         if args[field] and args[field] ~= "" then
         if args[field] and args[field] ~= "" then
Line 479: Line 441:
         end
         end
     end
     end
   
 
     -- Immunities Section (only if at least one immunity has a value)
     -- Immunities Section (only if at least one immunity has a value)
     if hasImmunities then
     if hasImmunities then
Line 489: Line 451:
       <td colspan="24" class="infobox-padding"></td>
       <td colspan="24" class="infobox-padding"></td>
     </tr>]]
     </tr>]]
       
 
         -- Poison immunity
         -- Poison immunity
         if args.poison_immunity and args.poison_immunity ~= "" then
         if args.poison_immunity and args.poison_immunity ~= "" then
Line 498: Line 460:
     </tr>]]
     </tr>]]
         end
         end
       
 
         -- Venom immunity
         -- Venom immunity
         if args.venom_immunity and args.venom_immunity ~= "" then
         if args.venom_immunity and args.venom_immunity ~= "" then
Line 507: Line 469:
     </tr>]]
     </tr>]]
         end
         end
       
 
         -- Cannon immunity
         -- Cannon immunity
         if args.cannon_immunity and args.cannon_immunity ~= "" then
         if args.cannon_immunity and args.cannon_immunity ~= "" then
Line 516: Line 478:
     </tr>]]
     </tr>]]
         end
         end
       
 
         -- Thrall immunity
         -- Thrall immunity
         if args.thrall_immunity and args.thrall_immunity ~= "" then
         if args.thrall_immunity and args.thrall_immunity ~= "" then
Line 525: Line 487:
     </tr>]]
     </tr>]]
         end
         end
       
 
         html = html .. [[
         html = html .. [[
     <tr>
     <tr>
Line 531: Line 493:
     </tr>]]
     </tr>]]
     end
     end
   
 
     -- DPS Calculator Button (optional, can be parameterized if needed)
     -- DPS Calculator Button (optional, can be parameterized if needed)
     if args.include_dps_calc and args.include_dps_calc == "yes" then
     if args.include_dps_calc and args.include_dps_calc == "yes" then
Line 539: Line 501:
     </tr>]]
     </tr>]]
     end
     end
   
 
     -- Advanced data section (if monster_id is provided)
     -- Advanced data section (if monster_id is provided)
     if args.monster_id and args.monster_id ~= "" then
     if args.monster_id and args.monster_id ~= "" then
Line 557: Line 519:
     </tr>]]
     </tr>]]
     end
     end
   
 
     html = html .. [[
     html = html .. [[
   </tr>
   </tr>
</table>]]
</table>]]
   
 
     return html
     return html
end
end
Line 569: Line 531:
     local args = frame:getParent().args
     local args = frame:getParent().args
     local output = "Received parameters:<br>"
     local output = "Received parameters:<br>"
   
 
     for k, v in pairs(args) do
     for k, v in pairs(args) do
         output = output .. k .. " = " .. v .. "<br>"
         output = output .. k .. " = " .. v .. "<br>"
     end
     end
   
 
     return output
     return output
end
end


return p
return p

Revision as of 03:04, 2 March 2025

Documentation for this module may be created at Module:InfoboxNPC/doc

local p = {}

function p.renderInfobox(frame)
    local args = frame.args
    local parent = frame:getParent()

    if parent then
        args = parent.args
    end

    local html = [[
<table class="infobox no-parenthesis-style infobox-item">
    <tr>
      <th colspan="24" class="infobox-header">]] .. (args.name or "Unknown Monster") .. [[</th>
    </tr>
    <tr>
      <td colspan="24" class="infobox-padding"></td>
    </tr>]]

    -- Character Image (conditional)
    if args.image and args.image ~= "" then
        html = html .. [[
    <tr>
      <td colspan="24" class="infobox-image infobox-full-width-content">]] .. "[[File:" .. args.image .. "|32px]]" ..
                   [[</td>
    </tr>
    <tr>
      <td colspan="24" class="infobox-padding"></td>
    </tr>]]
    end

    -- Basic Information (conditional for each row)
    local hasBasicInfo = false

    -- Released
    if args.released and args.released ~= "" then
        html = html .. [[
    <tr>
      <th colspan="8">Released</th>
      <td colspan="16">]] .. args.released .. [[</td>
    </tr>]]
        hasBasicInfo = true
    end

    -- Members
    if args.members and args.members ~= "" then
        html = html .. [[
    <tr>
      <th colspan="8">Members</th>
      <td colspan="16">]] .. args.members .. [[</td>
    </tr>]]
        hasBasicInfo = true
    end

    -- Combat level
    if args.combat_level and args.combat_level ~= "" then
        html = html .. [[
    <tr>
      <th colspan="8">Combat level</th>
      <td colspan="16">]] .. args.combat_level .. [[</td>
    </tr>]]
        hasBasicInfo = true
    end

    -- Size
    if args.size and args.size ~= "" then
        html = html .. [[
    <tr>
      <th colspan="8">Size</th>
      <td colspan="16">]] .. args.size .. [[</td>
    </tr>]]
        hasBasicInfo = true
    end

    -- Examine
    if args.examine and args.examine ~= "" then
        html = html .. [[
    <tr>
      <th colspan="8">Examine</th>
      <td colspan="16">]] .. args.examine .. [[</td>
    </tr>]]
        hasBasicInfo = true
    end

    -- League Information
    if args.league_region and args.league_region ~= "" then
        html = html .. [[
    <tr class="leagues-global-flag">
      <th colspan="8">League region</th>
      <td colspan="16">]] .. args.league_region .. [[</td>
    </tr>]]
        hasBasicInfo = true
    end

    -- Add padding if at least one basic info field was displayed
    if hasBasicInfo then
        html = html .. [[
    <tr>
      <td colspan="24" class="infobox-padding"></td>
    </tr>]]
    end

    -- Check if any combat info fields have values
    local hasCombatInfo = false
    local combatInfoFields = {"xp_bonus", "max_hit", "aggressive", "poisonous", "attack_style", "attack_speed",
                              "respawn_time"}

    for _, field in ipairs(combatInfoFields) do
        if args[field] and args[field] ~= "" then
            hasCombatInfo = true
            break
        end
    end

    -- Combat Information Section (only if at least one field has a value)
    if hasCombatInfo then
        html = html .. [[
    <tr>
      <th colspan="24" class="infobox-subheader">Combat info</th>
    </tr>
    <tr>
      <td colspan="24" class="infobox-padding"></td>
    </tr>]]

        -- XP Bonus
        if args.xp_bonus and args.xp_bonus ~= "" then
            html = html .. [[
    <tr>
      <th colspan="8">XP bonus</th>
      <td colspan="16">]] .. args.xp_bonus .. [[</td>
    </tr>]]
        end

        -- Max hit
        if args.max_hit and args.max_hit ~= "" then
            html = html .. [[
    <tr>
      <th colspan="8">Max hit</th>
      <td colspan="16">]] .. args.max_hit .. [[</td>
    </tr>]]
        end

        -- Aggressive
        if args.aggressive and args.aggressive ~= "" then
            html = html .. [[
    <tr>
      <th colspan="8">Aggressive</th>
      <td colspan="16">]] .. args.aggressive .. [[</td>
    </tr>]]
        end

        -- Poisonous
        if args.poisonous and args.poisonous ~= "" then
            html = html .. [[
    <tr>
      <th colspan="8">Poisonous</th>
      <td colspan="16">]] .. args.poisonous .. [[</td>
    </tr>]]
        end

        -- Attack style
        if args.attack_style and args.attack_style ~= "" then
            html = html .. [[
    <tr>
      <th colspan="8">Attack style</th>
      <td colspan="16">]] .. args.attack_style .. [[</td>
    </tr>]]
        end

        -- Attack speed
        if args.attack_speed and args.attack_speed ~= "" then
            html = html .. [[
    <tr>
      <th colspan="8">Attack speed</th>
      <td colspan="16">]] .. args.attack_speed .. [[</td>
    </tr>]]
        end

        -- Respawn time
        if args.respawn_time and args.respawn_time ~= "" then
            html = html .. [[
    <tr>
      <th colspan="8">Respawn time</th>
      <td colspan="16">]] .. args.respawn_time .. [[</td>
    </tr>]]
        end

        html = html .. [[
    <tr>
      <td colspan="24" class="infobox-padding"></td>
    </tr>]]
    end

    -- Check if any slayer info fields have values
    local hasSlayerInfo = false
    local slayerInfoFields = {"slayer_level", "slayer_xp", "slayer_category", "slayer_masters"}

    for _, field in ipairs(slayerInfoFields) do
        if args[field] and args[field] ~= "" then
            hasSlayerInfo = true
            break
        end
    end

    -- Slayer Section (only if at least one field has a value)
    if hasSlayerInfo then
        local slayerIcon = args.slayer_icon or "Slayer_icon.png"

        html = html .. [[
    <tr>
      <th colspan="24" class="infobox-subheader">]] .. "[[File:" .. slayerIcon .. "|23px]] Slayer info" .. [[</th>
    </tr>
    <tr>
      <td colspan="24" class="infobox-padding"></td>
    </tr>]]

        -- Slayer level
        if args.slayer_level and args.slayer_level ~= "" then
            html = html .. [[
    <tr>
      <th colspan="8">Slayer level</th>
      <td colspan="16">]] .. args.slayer_level .. [[</td>
    </tr>]]
        end

        -- Slayer XP
        if args.slayer_xp and args.slayer_xp ~= "" then
            html = html .. [[
    <tr>
      <th colspan="8">Slayer XP</th>
      <td colspan="16">]] .. args.slayer_xp .. [[</td>
    </tr>]]
        end

        -- Category
        if args.slayer_category and args.slayer_category ~= "" then
            html = html .. [[
    <tr>
      <th colspan="8">Category</th>
      <td colspan="16">]] .. args.slayer_category .. [[</td>
    </tr>]]
        end

        -- Assigned by
        if args.slayer_masters and args.slayer_masters ~= "" then
            html = html .. [[
    <tr>
      <th colspan="8">Assigned by</th>
      <td colspan="16">]] .. args.slayer_masters .. [[</td>
    </tr>]]
        end

        html = html .. [[
    <tr>
      <td colspan="24" class="infobox-padding"></td>
    </tr>]]
    end

    -- Check if any combat stats have values
    local hasCombatStats = false
    local combatStatFields = {"hitpoints", "attack", "strength", "defence", "magic", "ranged"}

    for _, field in ipairs(combatStatFields) do
        if args[field] and args[field] ~= "" then
            hasCombatStats = true
            break
        end
    end

    -- Combat Stats Section (only if at least one stat has a value)
    if hasCombatStats then
        local combatIcon = args.combat_icon or "Multicombat.png"
        local hitpointsIcon = args.hitpoints_icon or "Hitpoints_icon.png"
        local attackIcon = args.attack_icon or "Attack_icon.png"
        local strengthIcon = args.strength_icon or "Strength_icon.png"
        local defenceIcon = args.defence_icon or "Defence_icon.png"
        local magicIcon = args.magic_icon or "Magic_icon.png"
        local rangedIcon = args.ranged_icon or "Ranged_icon.png"

        html = html .. [[
    <tr>
      <th colspan="24" class="infobox-subheader">]] .. "[[File:" .. combatIcon .. "|19px]] Combat stats" .. [[</th>
    </tr>
    <tr>
      <td colspan="24" class="infobox-padding"></td>
    </tr>
    <tr>
      <th colspan="4" class="infobox-nested">]] .. "[[File:" .. hitpointsIcon .. "|23px]]" .. [[</th>
      <th colspan="4" class="infobox-nested">]] .. "[[File:" .. attackIcon .. "|25px]]" .. [[</th>
      <th colspan="4" class="infobox-nested">]] .. "[[File:" .. strengthIcon .. "|16px]]" .. [[</th>
      <th colspan="4" class="infobox-nested">]] .. "[[File:" .. defenceIcon .. "|17px]]" .. [[</th>
      <th colspan="4" class="infobox-nested">]] .. "[[File:" .. magicIcon .. "|25px]]" .. [[</th>
      <th colspan="4" class="infobox-nested">]] .. "[[File:" .. rangedIcon .. "|23px]]" .. [[</th>
    </tr>
    <tr>
      <td colspan="4" class="infobox-nested">]] .. (args.hitpoints or "") .. [[</td>
      <td colspan="4" class="infobox-nested">]] .. (args.attack or "") .. [[</td>
      <td colspan="4" class="infobox-nested">]] .. (args.strength or "") .. [[</td>
      <td colspan="4" class="infobox-nested">]] .. (args.defence or "") .. [[</td>
      <td colspan="4" class="infobox-nested">]] .. (args.magic or "") .. [[</td>
      <td colspan="4" class="infobox-nested">]] .. (args.ranged or "") .. [[</td>
    </tr>
    <tr>
      <td colspan="24" class="infobox-padding"></td>
    </tr>]]
    end

    -- Check if any aggressive stats have values
    local hasAggressiveStats = false
    local aggressiveStatFields = {"attack_bonus", "strength_bonus", "magic_bonus", "magic_damage", "ranged_bonus",
                                  "ranged_strength"}

    for _, field in ipairs(aggressiveStatFields) do
        if args[field] and args[field] ~= "" then
            hasAggressiveStats = true
            break
        end
    end

    -- Aggressive stats section (only if at least one stat has a value)
    if hasAggressiveStats then
        local attackIcon = args.attack_icon or "Attack_icon.png"
        local strengthIcon = args.strength_icon or "Strength_icon.png"
        local magicIcon = args.magic_icon or "Magic_icon.png"
        local magicDamageIcon = args.magic_damage_icon or "Magic_Damage_icon.png"
        local rangedIcon = args.ranged_icon or "Ranged_icon.png"
        local rangedStrengthIcon = args.ranged_strength_icon or "Ranged_Strength_icon.png"

        html = html .. [[
    <tr>
      <th colspan="24" class="infobox-subheader">]] .. "[[File:" .. attackIcon .. "|25px]] Aggressive stats" .. [[</th>
    </tr>
    <tr>
      <td colspan="24" class="infobox-padding"></td>
    </tr>
    <tr>
      <th colspan="4" class="infobox-nested">]] .. "[[File:" .. attackIcon .. "|25px]]" .. [[</th>
      <th colspan="4" class="infobox-nested">]] .. "[[File:" .. strengthIcon .. "|16px]]" .. [[</th>
      <th colspan="4" class="infobox-nested">]] .. "[[File:" .. magicIcon .. "|25px]]" .. [[</th>
      <th colspan="4" class="infobox-nested">]] .. "[[File:" .. magicDamageIcon .. "|28px]]" .. [[</th>
      <th colspan="4" class="infobox-nested">]] .. "[[File:" .. rangedIcon .. "|23px]]" .. [[</th>
      <th colspan="4" class="infobox-nested">]] .. "[[File:" .. rangedStrengthIcon .. "|26px]]" .. [[</th>
    </tr>
    <tr>
      <td colspan="4" class="infobox-nested">]] .. (args.attack_bonus or "") .. [[</td>
      <td colspan="4" class="infobox-nested">]] .. (args.strength_bonus or "") .. [[</td>
      <td colspan="4" class="infobox-nested">]] .. (args.magic_bonus or "") .. [[</td>
      <td colspan="4" class="infobox-nested">]] .. (args.magic_damage or "") .. [[</td>
      <td colspan="4" class="infobox-nested">]] .. (args.ranged_bonus or "") .. [[</td>
      <td colspan="4" class="infobox-nested">]] .. (args.ranged_strength or "") .. [[</td>
    </tr>
    <tr>
      <td colspan="24" class="infobox-padding"></td>
    </tr>]]
    end

    -- Check if any melee defence stats have values
    local hasMeleeDefence = false
    local meleeDefenceFields = {"stab_def", "slash_def", "crush_def"}

    for _, field in ipairs(meleeDefenceFields) do
        if args[field] and args[field] ~= "" then
            hasMeleeDefence = true
            break
        end
    end

    -- Check if any magic defence stats have values
    local hasMagicDefence = false
    local magicDefenceFields = {"magic_def"}

    for _, field in ipairs(magicDefenceFields) do
        if args[field] and args[field] ~= "" then
            hasMagicDefence = true
            break
        end
    end

    -- Check if any ranged defence stats have values
    local hasRangedDefence = false
    local rangedDefenceFields = {"ranged_def"}

    for _, field in ipairs(rangedDefenceFields) do
        if args[field] and args[field] ~= "" then
            hasRangedDefence = true
            break
        end
    end

    if hasRangedDefence then
        local rangedDefenceIcon = args.ranged_defence_icon or "Ranged_defence_icon.png"
    end

    if hasMagicDefence then
        local magicDefenceIcon = args.magic_defence_icon or "Magic_defence_icon.png"
    end

    -- Melee Defence Section (only if at least one defence stat has a value)
    if hasMeleeDefence or hasMagicDefence or hasRangedDefence then -- Check all types of defence.
        local defenceIcon = args.defence_icon or "Defence_icon.png"
        local stabIcon = args.stab_icon or "White_dagger.png"
        local slashIcon = args.slash_icon or "White_scimitar.png"
        local crushIcon = args.crush_icon or "White_warhammer.png"
        local rangedDefenceIcon = args.ranged_defence_icon or "Ranged_defence_icon.png"
        local magicDefenceIcon = args.magic_defence_icon or "Magic_defence_icon.png"

        html = html .. [[
    <tr>
        <th colspan="25" class="infobox-subheader">]] .. "[[File:" .. defenceIcon .. "|17px]] Defence" .. [[</th>
    </tr>
    <tr>
        <td colspan="25" class="infobox-padding"></td>
    </tr>
    <tr>
        <th colspan="5" class="infobox-nested">]] .. "[[File:" .. stabIcon .. "|21px]]" .. [[</th>
        <th colspan="5" class="infobox-nested">]] .. "[[File:" .. slashIcon .. "|27px]]" .. [[</th>
        <th colspan="5" class="infobox-nested">]] .. "[[File:" .. crushIcon .. "|22px]]" .. [[</th>
        <th colspan="5" class="infobox-nested">]] .. "[[File:" .. rangedDefenceIcon .. "|22px]]" .. [[</th>
        <th colspan="5" class="infobox-nested">]] .. "[[File:" .. magicDefenceIcon .. "|22px]]" .. [[</th>
    </tr>
    <tr>
        <td colspan="6" class="infobox-nested">]] .. (args.stab_def or "0") .. [[</td>
        <td colspan="6" class="infobox-nested">]] .. (args.slash_def or "0") .. [[</td>
        <td colspan="6" class="infobox-nested">]] .. (args.crush_def or "0") .. [[</td>
        <td colspan="6" class="infobox-nested">]] .. (args.ranged_def or "0") .. [[</td>
        <td colspan="24" class="infobox-nested">]] .. (args.magic_def or "0") .. [[</td>
    </tr>
    <tr>
        <td colspan="25" class="infobox-padding"></td>
    </tr>]]
    end

    -- Check if any immunity values have been specified
    local hasImmunities = false
    local immunityFields = {"poison_immunity", "venom_immunity", "cannon_immunity", "thrall_immunity"}

    for _, field in ipairs(immunityFields) do
        if args[field] and args[field] ~= "" then
            hasImmunities = true
            break
        end
    end

    -- Immunities Section (only if at least one immunity has a value)
    if hasImmunities then
        html = html .. [[
    <tr>
      <th colspan="24" class="infobox-subheader">Immunities</th>
    </tr>
    <tr>
      <td colspan="24" class="infobox-padding"></td>
    </tr>]]

        -- Poison immunity
        if args.poison_immunity and args.poison_immunity ~= "" then
            html = html .. [[
    <tr>
      <th colspan="8">Poison</th>
      <td colspan="16">]] .. args.poison_immunity .. [[</td>
    </tr>]]
        end

        -- Venom immunity
        if args.venom_immunity and args.venom_immunity ~= "" then
            html = html .. [[
    <tr>
      <th colspan="8">Venom</th>
      <td colspan="16">]] .. args.venom_immunity .. [[</td>
    </tr>]]
        end

        -- Cannon immunity
        if args.cannon_immunity and args.cannon_immunity ~= "" then
            html = html .. [[
    <tr>
      <th colspan="8">Cannons</th>
      <td colspan="16">]] .. args.cannon_immunity .. [[</td>
    </tr>]]
        end

        -- Thrall immunity
        if args.thrall_immunity and args.thrall_immunity ~= "" then
            html = html .. [[
    <tr>
      <th colspan="8">Thralls</th>
      <td colspan="16">]] .. args.thrall_immunity .. [[</td>
    </tr>]]
        end

        html = html .. [[
    <tr>
      <td colspan="24" class="infobox-padding"></td>
    </tr>]]
    end

    -- DPS Calculator Button (optional, can be parameterized if needed)
    if args.include_dps_calc and args.include_dps_calc == "yes" then
        html = html .. [[
    <tr>
      <td colspan="24" class="dps-calc-button infobox-full-width-content">DPS calculator button here</td>
    </tr>]]
    end

    -- Advanced data section (if monster_id is provided)
    if args.monster_id and args.monster_id ~= "" then
        html = html .. [[
    <tr class="advanced-data">
      <th colspan="24" class="infobox-subheader">Advanced data</th>
    </tr>
    <tr class="advanced-data">
      <td colspan="24" class="infobox-padding"></td>
    </tr>
    <tr class="advanced-data">
      <th colspan="8">Monster ID</th>
      <td colspan="16">]] .. args.monster_id .. [[</td>
    </tr>
    <tr class="advanced-data">
      <td colspan="24" class="infobox-padding"></td>
    </tr>]]
    end

    html = html .. [[
  </tr>
</table>]]

    return html
end

-- Function for testing/debugging - outputs what parameters were received
function p.debug(frame)
    local args = frame:getParent().args
    local output = "Received parameters:<br>"

    for k, v in pairs(args) do
        output = output .. k .. " = " .. v .. "<br>"
    end

    return output
end

return p