m (Capitalization) |
m (Most equipment isn't interesting enough to deserve a title) |
||
Line 6: | Line 6: | ||
p.view = {} | p.view = {} | ||
p.view['Name'] = dv.title{'name'} | p.view['Name'] = dv.text{'name'} | ||
p.view['Title'] = dv.title{'title', heading='Name', text='name'} | |||
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'} |
Revision as of 02:27, 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.text{'name'} p.view['Title'] = dv.title{'title', heading='Name', text='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