Module:Shortcut/policy
Jump to navigation
Jump to search
External links[edit source]
- Module:Shortcut/policy at Wikipedia, the free Terran-based encyclopedia that anyone can edit.
-- This module implements {{policy shortcut}}.
-- Set constants
local cfg = require('Module:Shortcut/config')
cfg['shortcut-heading'] = '[[Starfleet Logistics:Shortcut|Policy {{PLURAL:$1|shortcut|shortcuts}}]]'
-- Load required modules
local mShortcut = require('Module:Shortcut')
local p = {}
function p.main(frame)
local args = require('Module:Arguments').getArgs(frame, {
wrappers = 'Template:Policy shortcut'
})
-- Separate shortcuts from options
local shortcuts, options = {}, {}
for k, v in pairs(args) do
if type(k) == 'number' then
shortcuts[k] = v
else
options[k] = v
end
end
-- Compress the shortcut array, which may contain nils.
local function compressArray(t)
local nums, ret = {}, {}
for k in pairs(t) do
nums[#nums + 1] = k
end
table.sort(nums)
for i, num in ipairs(nums) do
ret[i] = t[num]
end
return ret
end
shortcuts = compressArray(shortcuts)
return mShortcut._main(shortcuts, options, frame, cfg)
end
return p