Add more descriptions to more-descriptions more-descriptions_v1.1.0

Mon, 30 Jun 2025 13:04:59 +0300

author
Teemu Piippo <teemu.s.piippo@gmail.com>
date
Mon, 30 Jun 2025 13:04:59 +0300
changeset 7
023ee666a3d6
parent 6
10ef96c4aa69
child 8
fa0a79b4099e

Add more descriptions to more-descriptions

more-descriptions/changelog.txt file | annotate | diff | comparison | revisions
more-descriptions/data-final-fixes.lua file | annotate | diff | comparison | revisions
more-descriptions/data.lua file | annotate | diff | comparison | revisions
more-descriptions/info.json file | annotate | diff | comparison | revisions
more-descriptions/locale/en/more-descriptions.cfg file | annotate | diff | comparison | revisions
more-descriptions/locale/en/show-refining-cost-in-tooltips.cfg file | annotate | diff | comparison | revisions
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/more-descriptions/changelog.txt	Mon Jun 30 13:04:59 2025 +0300
@@ -0,0 +1,8 @@
+---------------------------------------------------------------------------------------------------
+Version: 1.1.0
+Date: 2025-06-30
+  Major Features:
+    - Added a large amount of new descriptions, including:
+      - Agricultural tower dimensions
+      - List of possible ammo for guns and turrets
+      - Filter counts, stats, special behavior, etc
--- a/more-descriptions/data-final-fixes.lua	Sun Jun 29 23:37:36 2025 +0300
+++ b/more-descriptions/data-final-fixes.lua	Mon Jun 30 13:04:59 2025 +0300
@@ -1,3 +1,23 @@
+local function seconds(x)
+	return {"time-symbol-seconds", tostring(x)}
+end
+
+local function build_new_description(main_description, new_descriptions)
+	local new_localised_description = {
+		"",
+		main_description,
+	}
+	for i, k in pairs(new_descriptions)
+	do
+		if i ~= 1
+		then
+			table.insert(new_localised_description, "\n")
+		end
+		table.insert(new_localised_description, k)
+	end
+	return new_localised_description
+end
+
 local item_categories =
 {
 	"item",
@@ -99,6 +119,7 @@
 	"linked-container",
 	"proxy-container",
 	"heat-interface",
+	"heat-pipe",
 	"lane-splitter",
 	"linked-belt",
 	"valve",
@@ -163,14 +184,48 @@
 	return nil
 end
 
+local ammo_categories = {}
+
+for _, ammo in pairs(data.raw.ammo)
+do
+	if not ammo_categories[ammo.ammo_category]
+	then
+		ammo_categories[ammo.ammo_category] = ""
+	end
+	if #ammo_categories[ammo.ammo_category] < 120
+	then
+		ammo_categories[ammo.ammo_category] = ammo_categories[ammo.ammo_category].."[item="..ammo.name.."]"
+	elseif string.sub(ammo_categories[ammo.ammo_category], -3, -1) ~= "..."
+	then
+		ammo_categories[ammo.ammo_category] = ammo_categories[ammo.ammo_category] .. "..."
+	end
+end
+
 for _, item_type in pairs(item_categories)
 do
 	for _, item in pairs(data.raw[item_type] or {})
 	do
         local new_descriptions = {}
-		local refining_recipe = data.raw.recipe[item.name.."-refining"]
 		local recycling_recipe = data.raw.recipe[item.name.."-recycling"]
 
+		local add_description = function(x)
+			table.insert(new_descriptions, x)
+		end
+
+		local add_ammo_from_attack_parameters = function(attack_parameters)
+			if attack_parameters.ammo_category and ammo_categories[attack_parameters.ammo_category]
+			then
+				add_description{"more-descriptions-mod.gun-accepts-ammo", ammo_categories[attack_parameters.ammo_category]}
+			end
+			for _, category in pairs(attack_parameters.ammo_categories or {})
+			do
+				if ammo_categories[category]
+				then
+					add_description{"more-descriptions-mod.gun-accepts-ammo", ammo_categories[category]}
+				end
+			end
+		end
+
 		if recycling_recipe ~= nil
 		then
 			local recycling_results = {""}
@@ -178,29 +233,51 @@
 			do
 				table.insert(recycling_results, "[img="..result.type.."."..result.name.."]")
 			end
-            table.insert(new_descriptions, {
+            add_description{
                 "more-descriptions-mod.recycling",
-                tostring(recycling_recipe.energy_required),
+                seconds(recycling_recipe.energy_required),
 				recycling_results
-            })
+            }
 		end
 
 		if mods["promethium-quality"]
 		then
+			local refining_recipe = data.raw.recipe[item.name.."-refining"]
 			if refining_recipe ~= nil
 			then
-				table.insert(new_descriptions, {
+				add_description{
 					"more-descriptions-mod.refining-cost",
 					tostring(refining_recipe.energy_required),
-				})
+				}
 			elseif recycling_recipe ~= nil
 			then
-				table.insert(new_descriptions, {
-					"more-descriptions-mod.cannot-be-refined",
-				})
+				add_description{"more-descriptions-mod.cannot-be-refined"}
 			end
 		end
 
+		if item.type == "ammo" and (item.reload_time or 0) > 0
+		then
+			add_description{
+				"more-descriptions-mod.reload-time",
+				seconds(tostring(item.reload_time / 60.0)),
+			}
+		end
+
+		if item.type == "active-defense-equipment" and item.automatic
+		then
+			add_description{"more-descriptions-mod.fires-automatically"}
+		end
+
+		if item.type == "armor" and item.provides_flight
+		then
+			add_description{"more-descriptions-mod.armor-provides-flight"}
+		end
+
+		if item.type == "gun"
+		then
+			add_ammo_from_attack_parameters(item.attack_parameters)
+		end
+
 		local entity = item.place_result and find_entity(item.place_result) or nil
 		if entity ~= nil
 		then
@@ -209,11 +286,156 @@
 				local cb = entity.collision_box
 				local width = math.ceil(cb[2][1] - cb[1][1])
 				local height = math.ceil(cb[2][2] - cb[1][2])
-				table.insert(new_descriptions, {
+				add_description{
 					"more-descriptions-mod.size",
 					tostring(width),
 					tostring(height),
-				})
+				}
+			end
+
+			if entity.drops_full_belt_stacks
+			then
+				add_description{"more-descriptions-mod.drops-full-belt-stacks"}
+			end
+
+			if entity.heat_buffer and entity.heat_buffer.specific_heat
+			then
+				add_description{
+					"more-descriptions-mod.specific-heat",
+					entity.heat_buffer.specific_heat,
+				}
+			elseif entity.energy_source
+				and entity.energy_source.type == "heat"
+				and entity.energy_source.specific_heat
+			then
+				add_description{
+					"more-descriptions-mod.specific-heat",
+					entity.energy_source.specific_heat,
+				}
+			end
+
+			if entity.is_military_target
+			then
+				add_description{"more-descriptions-mod.is-military-target"}
+			end
+
+			if entity.type == "agricultural-tower"
+			then
+				local cb = entity.collision_box
+				local W = math.ceil(cb[2][1] - cb[1][1])
+				local w = (entity.growth_grid_tile_size or 3)
+				-- width of the "buffer" area around the agricultural tower
+				local z = (2 * w * math.ceil((W - w) / 2 / w)) + w
+				-- num of growth cells extending from the edges of the tower
+				local r = math.floor(entity.radius) -- why is it double..?
+				add_description{"more-descriptions-mod.agricultural-tower-num-inputs",
+					tostring(entity.input_inventory_size)
+				}
+				add_description{"more-descriptions-mod.agricultural-tower-growth-cell-size",
+					tostring(w)
+				}
+				add_description{"more-descriptions-mod.agricultural-tower-growth-cell-count",
+					tostring(4 * r * (r + (z / w)))
+				}
+				add_description{"more-descriptions-mod.agricultural-tower-total-size",
+					tostring(z + 2 * r * w)
+				}
+			elseif entity.type == "ammo-turret"
+			then
+				if entity.energy_per_shot ~= nil
+				then
+					add_description{"more-descriptions-mod.energy-per-shot-fired",
+						entity.energy_per_shot}
+				end
+				add_ammo_from_attack_parameters(entity.attack_parameters)
+			elseif entity.type == "beacon"
+			then
+				add_description{"more-descriptions-mod.beacon-supply-area-distance",
+					tostring(entity.supply_area_distance)
+				}
+			elseif entity.type == "car"
+			then
+				local immunities = ""
+				if (entity.immune_to_tree_impacts or false)
+				then
+					immunities = immunities.."[entity=tree-01]"
+				end
+				if (entity.immune_to_rock_impacts or false)
+				then
+					immunities = immunities.."[entity=big-rock]"
+				end
+				if (entity.immune_to_cliff_impacts or true)
+				then
+					immunities = immunities.."[entity=cliff]"
+				end
+				if immunities ~= ""
+				then
+					add_description{"more-descriptions-mod.car-immune-to-impacts", immunities}
+				end
+			elseif entity.type == "constant-combinator"
+			then
+				-- used by pushbutton mod
+				if (entity.pulse_duration or 0) > 60
+				then
+					add_description{"more-descriptions-mod.constant-combinator-pulse-duration",
+						seconds(entity.pulse_duration / 60.0)}
+				elseif (entity.pulse_duration or 0) > 0
+				then
+					add_description{"more-descriptions-mod.constant-combinator-pulse-duration",
+						{"more-descriptions-mod.ticks", tostring(entity.pulse_duration)}}
+				end
+			elseif (entity.type == "container" or entity.type == "logistic-container")
+			then
+				if entity.inventory_type == "with_filters_and_bar"
+				then
+					add_description{"more-descriptions-mod.container-filters"}
+				end
+			elseif entity.type == "cargo-wagon"
+			then
+				-- all cargo wagons support filters
+				add_description{"more-descriptions-mod.container-filters"}
+			elseif entity.type == "display-panel"
+			then
+				add_description{"more-descriptions-mod.display-panel-max-text-width",
+					tostring(entity.max_text_width or 400)}
+			elseif entity.type == "logistic-robot" or entity.type == "construction-robot"
+			then
+				if entity.speed_multiplier_when_out_of_energy > 0
+				then
+					add_description{"more-descriptions-mod.robot-speed-multiplier-when-out-of-energy",
+						tostring(entity.speed_multiplier_when_out_of_energy * 100)}
+				else
+					add_description{"more-descriptions-mod.robot-crashes-when-out-of-energy"}
+				end
+			elseif entity.type == "inserter"
+			then
+				if entity.wait_for_full_hand
+				then
+					add_description{"more-descriptions-mod.inserter-wait-for-full-hand",
+					tostring(entity.filter_count)}
+				end
+			elseif entity.type == "land-mine"
+			then
+				add_description{"more-descriptions-mod.land-mine-timeout",
+				seconds((entity.timeout or 120) / 60.0)}
+			elseif entity.type == "radar"
+			then
+				if entity.connects_to_other_radars ~= false
+				then
+					add_description{"more-descriptions-mod.radar-connection"}
+				end
+			end
+			if entity.filter_count
+			then
+				add_description{"more-descriptions-mod.filter-count",
+					tostring(entity.filter_count)}
+			end
+			for _, flag in pairs(entity.flags or {})
+			do
+				if flag == "no-automated-item-insertion"
+				then
+					table.insert(new_descriptions, {"more-descriptions-mod.no-automated-item-insertion"})
+				end
 			end
 		end
 
@@ -227,18 +449,7 @@
                     {"", {"item-description."..item.name}, "\n"},
                     ""
             }
-			item.localised_description = {
-				"",
-				main_description,
-			}
-			for i, k in pairs(new_descriptions)
-			do
-				if i ~= 1
-				then
-					table.insert(item.localised_description, "\n")
-				end
-				table.insert(item.localised_description, k)
-			end
+			item.localised_description = build_new_description(main_description, new_descriptions)
 		end
 	end
 end
@@ -261,17 +472,77 @@
 				{"", {"recipe-description."..recipe.name}, "\n"},
 				""
 		}
-		recipe.localised_description = {
-			"",
-			main_description,
-		}
-		for i, k in pairs(new_descriptions)
+		recipe.localised_description = build_new_description(main_description, new_descriptions)
+	end
+end
+
+-- Stuff mostly specific for entities that you don't place with items (like biters)
+for _, entity_category in pairs(entity_categories)
+do
+	for _, entity in pairs(data.raw[entity_category] or {})
+	do
+		local new_descriptions = {}
+
+		if entity.minable
+		then
+			table.insert(new_descriptions, {"more-descriptions-mod.mining-time",
+				seconds(entity.minable.mining_time)})
+		end
+
+		for _, flag in pairs(entity.flags or {})
 		do
-			if i ~= 1
+			if flag == "breaths-air"
+			then
+				table.insert(new_descriptions, {"more-descriptions-mod.breathes-air"})
+			end
+		end
+
+		if entity.type == "unit-spawner"
+		then
+			if (entity.time_to_capture or 0) > 0
 			then
-				table.insert(recipe.localised_description, "\n")
+				table.insert(new_descriptions, {"more-descriptions-mod.unit-spawner-time-to-capture",
+					seconds(entity.time_to_capture / 60.0)})
 			end
-			table.insert(recipe.localised_description, k)
+		end
+
+		if #new_descriptions > 0
+		then
+			local main_description = entity.localised_description
+				and {"", entity.localised_description, "\n"}
+				or {
+					"?",
+					{"", {"entity-description."..entity.name}, "\n"},
+					""
+			}
+			entity.localised_description = build_new_description(main_description, new_descriptions)
 		end
 	end
 end
+
+for _, space_location in pairs(data.raw["space-location"])
+do
+	local new_descriptions = {}
+
+	if (space_location.fly_condition or false)
+	then
+		table.insert(new_descriptions, {"more-descriptions-mod.space-location-fly-condition"})
+	end
+
+	if space_location.auto_save_on_first_trip == false -- (nil=true)
+	then
+		table.insert(new_descriptions, {"more-descriptions-mod.space-location-no-autosave"})
+	end
+
+	if #new_descriptions > 0
+	then
+		local main_description = space_location.localised_description
+			and {"", space_location.localised_description, "\n"}
+			or {
+				"?",
+				{"", {"space-location-description."..space_location.name}, "\n"},
+				""
+		}
+		space_location.localised_description = build_new_description(main_description, new_descriptions)
+	end
+end
\ No newline at end of file
--- a/more-descriptions/data.lua	Sun Jun 29 23:37:36 2025 +0300
+++ b/more-descriptions/data.lua	Mon Jun 30 13:04:59 2025 +0300
@@ -7,4 +7,4 @@
         height = 128,
         mipmap_count = 3,
     }
-}
\ No newline at end of file
+}
--- a/more-descriptions/info.json	Sun Jun 29 23:37:36 2025 +0300
+++ b/more-descriptions/info.json	Mon Jun 30 13:04:59 2025 +0300
@@ -1,6 +1,6 @@
 {
     "name": "more-descriptions",
-    "version": "1.0.0",
+    "version": "1.0.1",
     "author": "teemu",
     "description": "Adds more information like entity size to item and recipe descriptions.",
     "dependencies": ["? space-age", "? quality", "? promethium-quality"],
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/more-descriptions/locale/en/more-descriptions.cfg	Mon Jun 30 13:04:59 2025 +0300
@@ -0,0 +1,36 @@
+[more-descriptions-mod]
+ticks=__1__ __plural_for_parameter__1__{1=tick|rest=ticks}__
+refining-cost=[color=#fae8be][font=default-semibold]Refining cost:[/font][/color] __1__ [img=fluid.promethium-emulsion]
+recycling=[color=#fae8be][font=default-semibold]Recycling:[/font][/color] __1__ → __2__
+cannot-be-refined=[color=#fae8be][font=default-semibold]Cannot be refined[/font][/color]
+allows-productivity=[img=productivity-graphic][color=#fae8be][font=default-semibold]Allows productivity[/font][/color]
+size=[color=#fae8be][font=default-semibold]Entity size:[/font][/color] __1__ × __2__
+drops-full-belt-stacks=[color=#fae8be][font=default-semibold]Drops items as full stacks on belts[/font][/color]
+specific-heat=[color=#fae8be][font=default-semibold]Specific heat capacity:[/font][/color] __1__/°C
+reload-time=[color=#fae8be][font=default-semibold]Magazine reload time:[/font][/color] __1__
+is-military-target=[color=#fae8be][font=default-semibold]Is a military target[/font][/color]
+fires-automatically=[color=#fae8be][font=default-semibold]Fires automatically[/font][/color]
+agricultural-tower-num-inputs=[color=#fae8be][font=default-semibold]Input inventory size:[/font][/color] __1__
+agricultural-tower-growth-cell-size=[color=#fae8be][font=default-semibold]Planting cell size[/font][/color]: __1__ × __1__
+agricultural-tower-growth-cell-count=[color=#fae8be][font=default-semibold]Total planting cells[/font][/color]: __1__
+agricultural-tower-total-size=[color=#fae8be][font=default-semibold]Total farming dimensions[/font][/color]: __1__ × __1__
+armor-provides-flight=[color=#fae8be][font=default-semibold]Provides flight[/font][/color]
+energy-per-shot-fired=[color=#fae8be][font=default-semibold]Energy per shot fired[/font][/color]: __1__
+beacon-supply-area-distance=[color=#fae8be][font=default-semibold]Distribution range[/font][/color]: __1__
+car-immune-to-impacts=[color=#fae8be][font=default-semibold]Immune to impacts against:[/font][/color] __1__
+container-filters=[color=#fae8be][font=default-semibold]Allows item filters[/font][/color]
+display-panel-max-text-width=[color=#fae8be][font=default-semibold]Max. text width:[/font][/color] __1__
+mining-time=[color=#fae8be][font=default-semibold]Mining time:[/font][/color] __1__
+breathes-air=[color=#fae8be][font=default-semibold]Vulnerable to poison capsules[/font][/color]
+no-automated-item-insertion=[color=#fae8be][font=default-semibold]Cannot be automatically inserted items into[/font][/color]
+robot-speed-multiplier-when-out-of-energy=[color=#fae8be][font=default-semibold]Speed when out of energy:[/font][/color] __1__%
+robot-crashes-when-out-of-energy=[color=#fae8be][font=default-semibold]Crashes if runs out of energy[/font][/color]
+gun-accepts-ammo=[color=#fae8be][font=default-semibold]Accepts as ammo:[/font][/color] __1__
+filter-count=[color=#fae8be][font=default-semibold]Filter count:[/font][/color] __1__
+inserter-wait-for-full-hand=[color=#fae8be][font=default-semibold]Waits to fill its hand before swinging[/font][/color]
+land-mine-timeout=[color=#fae8be][font=default-semibold]Time until armed:[/font][/color] __1__
+radar-connection=[color=#fae8be][font=default-semibold]Wirelessly transmits circuit signals to other radars[/font][/color]
+constant-combinator-pulse-duration=[color=#fae8be][font=default-semibold]Stays on for:[/font][/color] __1__
+unit-spawner-time-to-capture=[color=#fae8be][font=default-semibold]Time to capture:[/font][/color] __1__
+space-location-fly-condition=[color=#fae8be][font=default-semibold]Uses a fly condition instead of a wait condition at destination[/font][/color]
+space-location-no-autosave=[color=#fae8be][font=default-semibold]No autosave for the first flight towards this location[/font][/color]
\ No newline at end of file
--- a/more-descriptions/locale/en/show-refining-cost-in-tooltips.cfg	Sun Jun 29 23:37:36 2025 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,6 +0,0 @@
-[more-descriptions-mod]
-refining-cost=[color=#fae8be][font=default-semibold]Refining cost:[/font][/color] __1__
-recycling=[color=#fae8be][font=default-semibold]Recycling:[/font][/color] __1__s → __2__
-cannot-be-refined=[color=#fae8be][font=default-semibold]Cannot be refined[/font][/color]
-allows-productivity=[img=productivity-graphic][color=#fae8be][font=default-semibold]Allows productivity[/font][/color]
-size=[color=#fae8be][font=default-semibold]Entity size:[/font][/color] __1__ × __2__
\ No newline at end of file

mercurial