Deprecated: ScribuntoContent overrides fillParserOutput which was deprecated in MediaWiki 1.38. [Called from MediaWiki\Content\Renderer\ContentRenderer::getParserOutput in /var/www/html/includes/content/Renderer/ContentRenderer.php at line 47] in /var/www/html/includes/debug/MWDebug.php on line 381

Deprecated: Use of AbstractContent::getParserOutput was deprecated in MediaWiki 1.38. [Called from ContentHandler::callDeprecatedContentGPO in /var/www/html/includes/content/ContentHandler.php at line 1883] in /var/www/html/includes/debug/MWDebug.php on line 381
Module:Equipment: Difference between revisions - ΔV: Wiki

Module:Equipment: Difference between revisions

From ΔV: Wiki
m (Pass through a caption to the table)
(columns for projectile magazines, nanodrone components, and propellant tanks)
Line 9: Line 9:
p.view['Price'] = dv.number{'price', unit='E$'}
p.view['Price'] = dv.number{'price', unit='E$'}
p.view['Mass'] = dv.number{'mass', unit='kg'}
p.view['Mass'] = dv.number{'mass', unit='kg'}
p.view['Manufacturer'] = dv.text{'manufacturer'}
-- Projectile magazines, nanodrone components, and propellant tanks
p.view['Storage'] = dv.number{'storage', unit='kg'}
p.view['Delivery'] = dv.number{'delivery', unit='kg/s'}
p.view['Exclusive To'] = dv.list{'exclusiveTo', itemView=dv.title{nil}}





Revision as of 01:50, 14 March 2023

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

local p = {}
local d = require('Module:Data')
local dv = require('Module:Data/View')


p.view = {}

p.view['Name'] = dv.title{'name'}
p.view['Price'] = dv.number{'price', unit='E$'}
p.view['Mass'] = dv.number{'mass', unit='kg'}
p.view['Manufacturer'] = dv.text{'manufacturer'}


-- Projectile magazines, nanodrone components, and propellant tanks
p.view['Storage'] = dv.number{'storage', unit='kg'}
p.view['Delivery'] = dv.number{'delivery', unit='kg/s'}
p.view['Exclusive To'] = dv.list{'exclusiveTo', itemView=dv.title{nil}}


-- Ultracapacitors
p.view['Energy Capacity'] = dv.number{'energyCapacity', unit='MJ'}
p.view['Peak Power'] = dv.number{'peakPower', unit='GW'}



for k,v in pairs(p.view) do
    v.heading = v.heading or k
end

p.defaultColumns = {
    'Name', 'Price', 'Mass'
}

p.positionalArgs = function(f)
    local posArgs = {}
    for i,posArg in ipairs(f.args) do
        -- positional arguments don't get trimmed
        table.insert(posArgs, mw.text.trim(posArg))
    end
    return posArgs
end

p.list = function(f)
    local posArgs = p.positionalArgs (f)
    local slot = table.remove(posArgs, 1)
    local columns = posArgs
    if table.getn(columns) == 0 then
        columns = p.defaultColumns
    end

    local data = mw.loadData('Module:Equipment/Data')
    data = data[slot]

    data = d.sort(data, {
        d.on(d.path{'price'}, d.asc),
        d.on(d.path{'name'}, d.asc),
    })

    local options = {
        caption = f.args['caption']
    }

    return dv.displayTable(data, p.view, columns, options)
end

return p