Jump to content

Module:USN fleet totals

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Trappist the monk (talk | contribs) at 14:11, 1 October 2022 (Created page with 'local data = mw.loadData ('Module:Sandbox/trappist the monk/USN fleet totals/data'); local fleet_totals = data.USN_fleet_totals; -- the big string of fleet totals local active_count = data.fleet_total; -- the grant total from the big string --[[--------------------------< U S N _ F L E E T _ T O T A L S >---------------------------------------------- This function returns one of two values: the long string of fleet totals created by Modu...'). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
(diff) ← Previous revision | Latest revision (diff) | Newer revision → (diff)

local data = mw.loadData ('Module:Sandbox/trappist the monk/USN fleet totals/data');
local fleet_totals = data.USN_fleet_totals;									-- the big string of fleet totals
local active_count = data.fleet_total;										-- the grant total from the big string

--[[--------------------------< U S N _ F L E E T _ T O T A L S >----------------------------------------------

This function returns one of two values:
	the long string of fleet totals created by Module:USN fleet totals			-- {{USN fleet totals}}
	the 'grand total' (active fleet) rounded to the nearest multiple of 5		-- {{USN fleet totals|<anything>}}

]]

local function USN_fleet_totals (frame)
	if not frame.args[1] or ('' == frame.args[1]) then							-- {{{1}}} empty or nil
		return fleet_totals;													-- return the detailed fleet totals
	else
		if 0 == active_count % 5 then
			return active_count;												-- <active_count> is xx0, xx5 so return unmolested
		elseif 2.5 > (active_count % 5) then
			return active_count - (active_count % 5);							-- <active_count> is xx1, xx2 so return xx0
		else
			return active_count + (5 - (active_count % 5));						-- <active_count> is xx3, xx4 so return xx5
		end
	end
end


--[[--------------------------< E X P O R T S >----------------------------------------------------------------
]]

return 
	{
	USN_fleet_totals = USN_fleet_totals,
	}