Module:Environmental Conditions

From Helldivers Wiki
Jump to navigation Jump to search

This module implements {{Environmental Conditions}}

Usage

To use this module in another Lua module, first you need to load it.

local envCond = require('Module:Environmental Conditions')

You can then get descriptions with

envCond._main(args)

The args variable should be a table containing the arguments to pass to the module. To see the different arguments that can be specified and how they affect the module output, please refer to the {{Environmental Conditions}} template documentation.

local getArgs = require ("Module:Arguments").getArgs

local p = {}


local switch = function(envDesc)
    local envDesc = string.lower(envDesc) or "default"
    case = {
        ["acid storms"] = function()
            return "<u>'''[[Acid Storms]]'''</u>: Corrosive acid storms '''temporarily reduce armor effectiveness''' for both enemy and friendly units."
        end,
        ["blizzards"] = function()
            return "<u>'''[[Blizzards]]'''</u>: Intense snowstorms '''reduce visibility'''."
        end,
        ["extreme cold"] = function()
            return "<u>'''[[Extreme Cold]]'''</u>: Icy temperatures '''reduce rate of fire''' and '''delay heat buildup in weapons'''."
        end,
        ["fire tornados"] = function()
            return "<u>'''[[Fire Tornados]]'''</u>: Planet is ravaged by '''deadly fire tornados'''."
        end,
        ["intense heat"] = function()
            return "<u>'''[[Intense Heat]]'''</u>: High temperatures '''increase stamina drain''' and '''speed up heat buildup in weapons'''."
        end,
        ["ion storms"] = function()
            return "<u>'''[[Ion Storms]]'''</u>: Ion storms intermittently '''disable [[Stratagems]]'''."
        end,
        ["meteor storms"] = function()
            return "<u>'''[[Meteor Storms]]'''</u>: Meteors impact the surface '''causing massive damage'''."
        end,
        ["rainstorms"] = function()
            return "<u>'''[[Rainstorms]]'''</u>: Torrential rainstorms '''reduce visibility'''."
        end,
        ["sandstorms"] = function()
            return "<u>'''[[Sandstorms]]'''</u>: Dense sandstorms '''reduce visibility'''."
        end,
        ["thick fog"] = function()
            return "<u>'''[[Thick Fog]]'''</u>: Dense fog '''reduces visibility'''."
        end,
        ["tremors"] = function()
            return "<u>'''[[Tremors]]'''</u>: Frequent earthquakes stun '''players and enemies''' alike."
        end,
        ["volcanic activity"] = function()
            return "<u>'''[[Volcanic Activity]]'''</u>: Volcanos '''throw burning rocks''' around this planet."
        end,
        ["none"] = function()
            return "<u>'''None'''</u>"
        end,
        default = function()
            return "Unknown Condition"
        end
    }

    if case[envDesc] then
        return case[envDesc]()
    else
        return case["default"]()
    end
end

function p.main(frame)
    local args = getArgs(frame)
    return p._main(args)
end

function p._main(args)
    local output = ""
    for _, arg in ipairs(args) do
        output = output .. "<span>" .. switch(arg) .. "</span>" .. "<br>"
    end
    return output
end

return p