Module:Location

From Pacific Drive Wiki

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

local p = {}

p.locations = {
    damp_forest = {
        name = 'Damp Forest',
        icon = 'DampForest.png',
        color = '#76b745'
    },
    blistering_woods = {
        name = 'Blistering Woods',
        icon = 'BlisteringWoods.png',
        color = '#e49748'
    },
    the_mires = {
        name = 'The Mires',
        icon = 'TheMires.png',
        color = '#0b9791'
    },
    the_scorch = {
        name = 'The Scorch',
        icon = 'TheScorch.png',
        color = '#c4b83d'
    },
    smokestacks = {
        name = 'Smokestacks',
        icon = 'Smokestacks.png',
        color = '#c6201c'
    },
    red_spires = {
        name = 'Red Spires',
        icon = 'RedSpires.png',
        color = '#8d7a90'
    },
    workbench1 = {
        name = 'Workbench Lv.1',
        icon = 'Craft-Bench-1.png',
        color = '#272627',
    },
    workbench2 = {
        name = 'Workbench Lv.2',
        icon = 'Craft-Bench-2.png',
        color = '#272627',
    }
}

function p.main(frame)
    local res = ''
    local locs = frame.args.locations .. ','
    for loc in locs:gmatch("([%w_]+),") do
        local location = p.locations[loc]
        if not location then
            return string.format("Location %s not found.", loc)
        end
        res = string.format(
            '%s<div style="color: #eaecc3; display: flex; align-items: center; width: fit-content; padding: 0; margin: 0; border: solid; border-color: %s; border-width: 2px;"><span style="margin: 0; padding-left: 8px; padding-right: 8px;">[[File:%s|26px|alt=Icon for the %s location]]</span><span style="border-left: solid; border-color: %s; border-width: 2px; font-size: 24px; width: 8em; padding: 2px 8px 2px 8px; margin: 0;">[[%s]]</div>',
            res, location.color, location.icon, location.name, location.color, location.name)
    end
    return res
end

return p