Open main menu
Home
Random
Donate
Recent changes
Special pages
Community portal
Preferences
About Stockhub
Disclaimers
Search
User menu
Talk
Contributions
Create account
Log in
Editing
Module:USN fleet totals
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
local data = mw.loadData ('Module:USN fleet totals/data'); -- get the detailed list of ship types and their counts, the grand total of active and reserve ships, and the total planned ships --[[--------------------------< R O U N D >-------------------------------------------------------------------- rounds <count> to nearest multiple of 5. ]] local function round (count) if 0 == count % 5 then return count; -- <count> is xx0, xx5 so return unmolested elseif 2.5 > (count % 5) then return count - (count % 5); -- <count> is xx1, xx2 so return xx0 else return count + (5 - (count % 5)); -- <count> is xx3, xx4 so return xx5 end end --[[--------------------------< U S N _ F L E E T _ T O T A L S >---------------------------------------------- implements {{USN fleet totals}} This function returns one of three values according to the text sting in {{{1}}} (frame.args[1]): active β the 'grand total' (active and reserved fleets) rounded to the nearest multiple of 5 -- {{USN fleet totals|active}} planned β the 'planned total' (ships under construction or on order) rounded to the nearest multiple of 5 -- {{USN fleet totals|planned}} <anything or nothing> β the long string of fleet totals created by Module:USN fleet totals -- {{USN fleet totals}} ]] local function USN_fleet_totals (frame) if 'active' == frame.args[1] then -- number of active and reseved fleet ships return round (data.grand_total); -- round to nearest multiple of 5 elseif 'planned' == frame.args[1] then -- under of under construction and on-order ships return round (data.planned_total); -- round to nearest multiple of 5 else -- {{{1}}} is anything else return data.fleet_totals_str; -- return the detailed fleet totals end end --[[--------------------------< E X P O R T S >---------------------------------------------------------------- ]] return { USN_fleet_totals = USN_fleet_totals, }
Summary:
Please note that all contributions to Stockhub may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Stockhub:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Templates used on this page:
Template:Sandbox other
(
edit
)
Template:Tlx
(
edit
)
Module:Arguments
(
edit
)
Module:String
(
edit
)
Module:Template link general
(
edit
)
Module:USN fleet totals/doc
(
edit
)