<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.warexpand.com/index.php?action=history&amp;feed=atom&amp;title=Module%3AAmmoStats</id>
	<title>Module:AmmoStats - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.warexpand.com/index.php?action=history&amp;feed=atom&amp;title=Module%3AAmmoStats"/>
	<link rel="alternate" type="text/html" href="https://wiki.warexpand.com/index.php?title=Module:AmmoStats&amp;action=history"/>
	<updated>2026-10-12T07:04:05Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.11</generator>
	<entry>
		<id>https://wiki.warexpand.com/index.php?title=Module:AmmoStats&amp;diff=187&amp;oldid=prev</id>
		<title>Warmaninger: Import generated wiki content (units, buildings, fortifications, overview, categories)</title>
		<link rel="alternate" type="text/html" href="https://wiki.warexpand.com/index.php?title=Module:AmmoStats&amp;diff=187&amp;oldid=prev"/>
		<updated>2026-08-21T22:48:48Z</updated>

		<summary type="html">&lt;p&gt;Import generated wiki content (units, buildings, fortifications, overview, categories)&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;-- Renders ammunition statistics from [[Module:Data/Ammo]].&lt;br /&gt;
--&lt;br /&gt;
-- This module is hand-written, in the same style as Module:UnitStats.&lt;br /&gt;
-- Module:Data/Ammo is meant to be generated by scripts/export-wiki-data.cjs&lt;br /&gt;
-- (which only writes under the Module:Data/ prefix), so this file is never&lt;br /&gt;
-- overwritten by the export.&lt;br /&gt;
--&lt;br /&gt;
-- Entry point:&lt;br /&gt;
--   table  - one row per ammunition   {{#invoke:AmmoStats|table}}  or  {{#invoke:AmmoStats|table|kind=unit}}&lt;br /&gt;
--&lt;br /&gt;
-- Expected shape of Module:Data/Ammo (field names follow the game&amp;#039;s ammo&lt;br /&gt;
-- table: volume, craft_time, batch_size, required_&amp;lt;resource&amp;gt;, and for&lt;br /&gt;
-- strategic ordnance impact_radius_meters, loss_percent, build_time):&lt;br /&gt;
--&lt;br /&gt;
--   return {&lt;br /&gt;
--     light_infantry_ammo = {&lt;br /&gt;
--       name       = &amp;#039;Rifle Rounds&amp;#039;,&lt;br /&gt;
--       kind       = &amp;#039;unit&amp;#039;,            -- &amp;#039;unit&amp;#039; | &amp;#039;fortification&amp;#039; | &amp;#039;strategic&amp;#039;&lt;br /&gt;
--       fired_by   = &amp;#039;Light Infantry&amp;#039;,  -- optional, wiki page name&lt;br /&gt;
--       volume     = 0.5,               -- m3 per unit, optional&lt;br /&gt;
--       craft_time = &amp;#039;10m&amp;#039;,             -- optional&lt;br /&gt;
--       batch_size = 100,               -- optional&lt;br /&gt;
--       cost       = { money = 50, metal = 10, concrete = 0, petrol = 0, uranium = 0 },&lt;br /&gt;
--       impact_radius = 5000,           -- metres, strategic only&lt;br /&gt;
--       loss_percent  = 40,             -- strategic only&lt;br /&gt;
--     },&lt;br /&gt;
--   }&lt;br /&gt;
&lt;br /&gt;
local p = {}&lt;br /&gt;
&lt;br /&gt;
local loaded, data = pcall( mw.loadData, &amp;#039;Module:Data/Ammo&amp;#039; )&lt;br /&gt;
if not loaded then&lt;br /&gt;
	data = nil&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local PENDING = &amp;quot;&amp;#039;&amp;#039;Stats not yet available.&amp;#039;&amp;#039;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
local RESOURCES = { &amp;#039;money&amp;#039;, &amp;#039;food&amp;#039;, &amp;#039;metal&amp;#039;, &amp;#039;concrete&amp;#039;, &amp;#039;petrol&amp;#039;, &amp;#039;uranium&amp;#039; }&lt;br /&gt;
local KIND_ORDER = { unit = 1, fortification = 2, strategic = 3 }&lt;br /&gt;
local KIND_LABEL = { unit = &amp;#039;Unit&amp;#039;, fortification = &amp;#039;Fortification&amp;#039;, strategic = &amp;#039;Strategic&amp;#039; }&lt;br /&gt;
&lt;br /&gt;
local function formatResources( bundle )&lt;br /&gt;
	if not bundle then&lt;br /&gt;
		return nil&lt;br /&gt;
	end&lt;br /&gt;
	local parts = {}&lt;br /&gt;
	for _, name in ipairs( RESOURCES ) do&lt;br /&gt;
		local amount = bundle[name]&lt;br /&gt;
		if amount and amount &amp;gt; 0 then&lt;br /&gt;
			parts[#parts + 1] = string.format( &amp;#039;%s %s&amp;#039;, amount, name )&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	if #parts == 0 then&lt;br /&gt;
		return &amp;#039;free&amp;#039;&lt;br /&gt;
	end&lt;br /&gt;
	return table.concat( parts, &amp;#039;, &amp;#039; )&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function cell( value )&lt;br /&gt;
	if value == nil or value == &amp;#039;&amp;#039; then&lt;br /&gt;
		return &amp;#039;| -\n&amp;#039;&lt;br /&gt;
	end&lt;br /&gt;
	return string.format( &amp;#039;| %s\n&amp;#039;, value )&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--- Table of every ammunition, optionally filtered by kind.&lt;br /&gt;
-- Usage: {{#invoke:AmmoStats|table|kind=fortification}}&lt;br /&gt;
function p.table( frame )&lt;br /&gt;
	if not data then&lt;br /&gt;
		return PENDING&lt;br /&gt;
	end&lt;br /&gt;
	local wanted = frame.args.kind&lt;br /&gt;
	if wanted == &amp;#039;&amp;#039; then&lt;br /&gt;
		wanted = nil&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	local codes = {}&lt;br /&gt;
	for code, ammo in pairs( data ) do&lt;br /&gt;
		if not wanted or ammo.kind == wanted then&lt;br /&gt;
			codes[#codes + 1] = code&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	table.sort( codes, function( a, b )&lt;br /&gt;
		local ka, kb = KIND_ORDER[data[a].kind] or 9, KIND_ORDER[data[b].kind] or 9&lt;br /&gt;
		if ka ~= kb then&lt;br /&gt;
			return ka &amp;lt; kb&lt;br /&gt;
		end&lt;br /&gt;
		return ( data[a].name or a ) &amp;lt; ( data[b].name or b )&lt;br /&gt;
	end )&lt;br /&gt;
	if #codes == 0 then&lt;br /&gt;
		return &amp;quot;&amp;#039;&amp;#039;No ammunition of this kind.&amp;#039;&amp;#039;&amp;quot;&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	local strategic = false&lt;br /&gt;
	for _, code in ipairs( codes ) do&lt;br /&gt;
		if data[code].kind == &amp;#039;strategic&amp;#039; then&lt;br /&gt;
			strategic = true&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	local out = {&lt;br /&gt;
		&amp;#039;{| class=&amp;quot;wikitable sortable&amp;quot; style=&amp;quot;text-align:center&amp;quot;\n&amp;#039;,&lt;br /&gt;
		&amp;#039;! Ammunition !! Kind !! Fired by !! Batch size !! Craft time !! Batch cost !! Volume (m³)&amp;#039;,&lt;br /&gt;
	}&lt;br /&gt;
	if strategic then&lt;br /&gt;
		out[#out + 1] = &amp;#039; !! Impact radius !! Losses&amp;#039;&lt;br /&gt;
	end&lt;br /&gt;
	out[#out + 1] = &amp;#039;\n&amp;#039;&lt;br /&gt;
	for _, code in ipairs( codes ) do&lt;br /&gt;
		local a = data[code]&lt;br /&gt;
		out[#out + 1] = &amp;#039;|-\n&amp;#039;&lt;br /&gt;
		out[#out + 1] = cell( a.name or code )&lt;br /&gt;
		out[#out + 1] = cell( KIND_LABEL[a.kind] or a.kind )&lt;br /&gt;
		out[#out + 1] = cell( a.fired_by and string.format( &amp;#039;[[%s]]&amp;#039;, a.fired_by ) or nil )&lt;br /&gt;
		out[#out + 1] = cell( a.batch_size )&lt;br /&gt;
		out[#out + 1] = cell( a.craft_time )&lt;br /&gt;
		out[#out + 1] = cell( formatResources( a.cost ) )&lt;br /&gt;
		out[#out + 1] = cell( a.volume )&lt;br /&gt;
		if strategic then&lt;br /&gt;
			out[#out + 1] = cell( a.impact_radius and string.format( &amp;#039;%s m&amp;#039;, a.impact_radius ) or nil )&lt;br /&gt;
			out[#out + 1] = cell( a.loss_percent and string.format( &amp;#039;%s%%&amp;#039;, a.loss_percent ) or nil )&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	out[#out + 1] = &amp;#039;|}&amp;#039;&lt;br /&gt;
	return table.concat( out )&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
return p&lt;/div&gt;</summary>
		<author><name>Warmaninger</name></author>
	</entry>
</feed>