Add more descriptions mod more-descriptions-v1.0.0

Sun, 29 Jun 2025 23:37:19 +0300

author
Teemu Piippo <teemu.s.piippo@gmail.com>
date
Sun, 29 Jun 2025 23:37:19 +0300
changeset 5
4418c07556d4
parent 4
01053f3be1a6
child 6
10ef96c4aa69

Add more descriptions mod

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/show-refining-cost-in-tooltips.cfg file | annotate | diff | comparison | revisions
more-descriptions/thumbnail.png file | annotate | diff | comparison | revisions
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/more-descriptions/data-final-fixes.lua	Sun Jun 29 23:37:19 2025 +0300
@@ -0,0 +1,277 @@
+local item_categories =
+{
+	"item",
+	"item-with-entity-data",
+	"rail-planner",
+	"capsule",
+	"repair-tool",
+	"blueprint",
+	"deconstruction-item",
+	"upgrade-item",
+	"blueprint-book",
+	"copy-paste-tool",
+	"module",
+	"tool",
+	"gun",
+	"ammo",
+	"space-platform-starter-pack",
+	"armor",
+	"spidertron-remote",
+}
+
+local entity_categories =
+{
+	"container",
+	"storage-tank",
+	"transport-belt",
+	"underground-belt",
+	"splitter",
+	"loader",
+	"inserter",
+	"electric-pole",
+	"pipe",
+	"pipe-to-ground",
+	"pump",
+	"straight-rail",
+	"half-diagonal-rail",
+	"curved-rail-a",
+	"curved-rail-b",
+	"elevated-straight-rail",
+	"elevated-half-diagonal-rail",
+	"elevated-curved-rail-a",
+	"elevated-curved-rail-b",
+	"legacy-straight-rail",
+	"legacy-curved-rail",
+	"rail-ramp",
+	"rail-support",
+	"train-stop",
+	"rail-signal",
+	"rail-chain-signal",
+	"locomotive",
+	"cargo-wagon",
+	"fluid-wagon",
+	"artillery-wagon",
+	"car",
+	"spider-vehicle",
+	"logistic-robot",
+	"construction-robot",
+	"logistic-container",
+	"roboport",
+	"lamp",
+	"arithmetic-combinator",
+	"decider-combinator",
+	"selector-combinator",
+	"constant-combinator",
+	"power-switch",
+	"programmable-speaker",
+	"display-panel",
+	"boiler",
+	"generator",
+	"fusion-reactor",
+	"fusion-generator",
+	"mining-drill",
+	"offshore-pump",
+	"furnace",
+	"assembling-machine",
+	"agricultural-tower",
+	"lab",
+	"lightning-attractor",
+	"reactor",
+	"beacon",
+	"rocket-silo",
+	"cargo-landing-pad",
+	"space-platform-hub",
+	"cargo-bay",
+	"asteroid-collector",
+	"thruster",
+	"wall",
+	"gate",
+	"radar",
+	"land-mine",
+	"ammo-turret",
+	"electric-turret",
+	"fluid-turret",
+	"artillery-turret",
+	"plant",
+	"simple-entity-with-force",
+	"simple-entity-with-owner",
+	"electric-energy-interface",
+	"linked-container",
+	"proxy-container",
+	"heat-interface",
+	"lane-splitter",
+	"linked-belt",
+	"valve",
+	"infinity-cargo-wagon",
+	"infinity-container",
+	"infinity-pipe",
+	"burner-generator",
+	"resource",
+	"cargo-pod",
+	"temporary-container",
+	"asteroid",
+	"combat-robot",
+	"unit",
+	"turret",
+	"unit-spawner",
+	"spider-unit",
+	"segmented-unit",
+	"cliff",
+	"character",
+	"fish",
+	"tree",
+	"simple-entity",
+	"lightning",
+	"corpse",
+	"rail-remnants",
+	"explosion",
+	"particle-source",
+	"fire",
+	"sticker",
+	"stream",
+	"artillery-flare",
+	"artillery-projectile",
+	"projectile",
+	"segment",
+	"spider-leg",
+	"beam",
+	"character-corpse",
+	"speech-bubble",
+	"smoke-with-trigger",
+	"entity-ghost",
+	"arrow",
+	"highlight-box",
+	"item-entity",
+	"item-request-proxy",
+	"loader-1x1",
+	"rocket-silo-rocket",
+	"rocket-silo-rocket-shadow",
+	"tile-ghost",
+	"market",
+	"capture-robot",
+	"solar-panel",
+}
+
+local function find_entity(name)
+	for _, entity_category in pairs(entity_categories)
+	do
+		if data.raw[entity_category] and data.raw[entity_category][name]
+		then
+			return data.raw[entity_category][name]
+		end
+	end
+	return nil
+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"]
+
+		if recycling_recipe ~= nil
+		then
+			local recycling_results = {""}
+			for _, result in pairs(recycling_recipe.results)
+			do
+				table.insert(recycling_results, "[img="..result.type.."."..result.name.."]")
+			end
+            table.insert(new_descriptions, {
+                "more-descriptions-mod.recycling",
+                tostring(recycling_recipe.energy_required),
+				recycling_results
+            })
+		end
+
+		if mods["promethium-quality"]
+		then
+			if refining_recipe ~= nil
+			then
+				table.insert(new_descriptions, {
+					"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",
+				})
+			end
+		end
+
+		local entity = item.place_result and find_entity(item.place_result) or nil
+		if entity ~= nil
+		then
+			if entity.collision_box
+			then
+				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, {
+					"more-descriptions-mod.size",
+					tostring(width),
+					tostring(height),
+				})
+			end
+		end
+
+		if #new_descriptions > 0
+		then
+			local main_description = item.localised_description
+                and {"", item.localised_description, "\n"}
+                or {
+                    "?",
+                    {"", {"entity-description."..item.name}, "\n"},
+                    {"", {"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
+		end
+	end
+end
+
+for _, recipe in pairs(data.raw.recipe)
+do
+	local new_descriptions = {}
+
+	if recipe.allow_productivity
+	then
+		table.insert(new_descriptions, {"more-descriptions-mod.allows-productivity"})
+	end
+
+	if #new_descriptions > 0
+	then
+		local main_description = recipe.localised_description
+			and {"", recipe.localised_description, "\n"}
+			or {
+				"?",
+				{"", {"recipe-description."..recipe.name}, "\n"},
+				""
+		}
+		recipe.localised_description = {
+			"",
+			main_description,
+		}
+		for i, k in pairs(new_descriptions)
+		do
+			if i ~= 1
+			then
+				table.insert(recipe.localised_description, "\n")
+			end
+			table.insert(recipe.localised_description, k)
+		end
+	end
+end
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/more-descriptions/data.lua	Sun Jun 29 23:37:19 2025 +0300
@@ -0,0 +1,10 @@
+data:extend{
+    {
+        type = "sprite",
+        name = "productivity-graphic",
+        filename = "__core__/graphics/icons/technology/constants/constant-recipe-productivity.png",
+        width = 128,
+        height = 128,
+        mipmap_count = 3,
+    }
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/more-descriptions/info.json	Sun Jun 29 23:37:19 2025 +0300
@@ -0,0 +1,9 @@
+{
+    "name": "more-descriptions",
+    "version": "1.0.0",
+    "author": "teemu",
+    "description": "Adds more information like entity size to item and recipe descriptions.",
+    "dependencies": ["? space-age", "? quality", "? promethium-quality"],
+    "factorio_version": "2.0",
+    "title": "More descriptive descriptions"
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/more-descriptions/locale/en/show-refining-cost-in-tooltips.cfg	Sun Jun 29 23:37:19 2025 +0300
@@ -0,0 +1,6 @@
+[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
Binary file more-descriptions/thumbnail.png has changed

mercurial