(Autopilot column views) |
(Drone columns) |
||
Line 12: | Line 12: | ||
p.view['Manufacturer'] = dv.text{'manufacturer'} | p.view['Manufacturer'] = dv.text{'manufacturer'} | ||
p.view['Effective range'] = dv.number{'effectiveRange', unit='m'} | |||
p.view['Power draw'] = dv.number{'powerDraw', unit='MW'} | |||
-- Drones | |||
p.view['Drones per second'] = dv.number{'droneLaunchCapability'} | |||
p.view['Drone wet mass'] = dv.number{'droneWetMass', unit='kg'} | |||
p.view['Drone thrust'] = dv.number{'droneThrust', unit='kN'} | |||
-- Projectile magazines, nanodrone components, and propellant tanks | -- Projectile magazines, nanodrone components, and propellant tanks |
Revision as of 18:22, 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'} p.view['Effective range'] = dv.number{'effectiveRange', unit='m'} p.view['Power draw'] = dv.number{'powerDraw', unit='MW'} -- Drones p.view['Drones per second'] = dv.number{'droneLaunchCapability'} p.view['Drone wet mass'] = dv.number{'droneWetMass', unit='kg'} p.view['Drone thrust'] = dv.number{'droneThrust', unit='kN'} -- 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'} -- Autopilots p.view['AAT'] = dv.flag{'aat', heading='[[Autopilot#AAT|AAT]]'} p.view['ARL'] = dv.flag{'arl', heading='[[Autopilot#ARL|ARL]]'} p.view['RTC'] = dv.flag{'rtc', heading='[[Autopilot#RTC|RTC]]'} p.view['FBW'] = dv.flag{'fbw', heading='[[Autopilot#FBW|FBW]]'} p.view['Autopilot capabilities'] = dv.list{'autopilotCapabilities', heading='Capabilities', itemView=dv.text{nil}} 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