A Weird Imagination

Devlog: Pacifist Factorio mod PRs (1 of 3): strings, strings, strings

The problem#

I wanted to introduce Factorio to some younger cousins but didn't think the military aspects of the game would be appropriate for them, both because their parents would rather they not be playing violent video games and it's simply an additional distraction and added complexity in a game that's already fairly involved, especially for a child.

Due to Factorio's active modding community, often if you can think of a mod you want, someone else has already thought of it and implemented it. And it turned out I'm not the first person to a less violent Factorio: Pacifist already existed and did most of what I wanted. Like many Factorio mods, it's open-source and has a GitHub page. The developer was very friendly and helpful, so I was able to contribute changes get them into the next release of the mod.

My contributions weren't fixing bugs in the mod as much as nudging its goals in a slightly different direction: it was already removing the military aspect from the gameplay, but I also wanted to remove hints of it from the UI as much as possible.

The solution#

Play Factorio with Pacifist, which now includes my changes. I recommend also including my mod BackpackRename. Additionally, I found the StartAlt and Attention Indicator mods good for playing with new players.

The details#

Finding issues#

To find possible issues, I just opened the game with Pacifist and tried things in the game. In order to quickly get different setups including viewing the win screen, I used the in-game cheats via the console. I also needed the cheats to unlock circuits and trains so I could see the dialogs for selecting signals for circuits and rich text for train stop names. (I later noticed the rich text dialog is also available when typing a chat message and therefore did not actually require a technology to be unlocked.)

There's a lot of different places to look for strings in game. Some easy to miss details include that the tooltip for a recipe is different from the tooltip for an item (especially noticable on armors), which is again different from the info pane that shows up on the right side of the screen when hovering over an entity to see its current status. Additionally, I found some strings of interest by simply searching for words like "gun", "armor", or "kill" in game's localization files. Once I saw them there, I was able to figure where the strings were actually used in game to decide how I wanted to reword them.

Editing strings1#

(See also: Factorio wiki "Tutorial:Localisation")

To change a string that exists in the base game (or another mod), you just define it in the translations file like any other string your mod may use. Localized strings appear to be loaded in dependency order, so if you want your mod to override another mod's string, make sure your mod has a dependency on that mod (if you don't actually require that mod, it can be a (hidden or not) optional dependency).

To determine the name of the string, look at the locale file for the mod. Or for the base game, under your Factorio install there's data/core/locale and data/base/locale directories for the strings built into the game (core is what's actually built into the game, base is the mod that is almost always loaded but is technically optional). Note that once you find the string, you'll have to scroll up to find the [category] it is in and make sure the replacement string in your mod is in the matching category.

Last, scenarios, including the default "Freeplay" scenario, have their own localized strings that cannot be overridden this way. Since scenarios are stored in the save file, my workaround was to simply edit the save file, as it's just a ZIP file containing, among other data, the full scenario including its locale directory. If you actually wanted to make a mod that "edited" the strings in the Freeplay scenario, you'd have to actually make of a copy of it in your mod and modify the copy.

Interpretation of empty strings#

One non-obvious detail is that Factorio will do the right thing if you set a tooltip to an empty string. That is, that will disable that tooltip entirely, it won't try to display an empty tooltip. On the other hand, if you set a string used as a label to the empty string, then Factorio will still show the value, although it won't show the colon that would be added after a non-empty label. For example, in core there's the definition

shield-capacity=Shield capacity

which is shown in the tooltip for armors as "Shield capacity: 0". In my BackpackRename mod, I remove the "Shield capacity" by doing


which results in the armor tooltip showing "0" (note the ": " is missing). As I couldn't figure out anything better, I decided that was good enough. If you look closely, you'll notice the lone "0" below the equipment grid, but it's easy to miss.

Depending on what the value is, you may be able to hide it by modifying the prototype to remove the value, as I did for resistances on armors and pollution statistics, but, of course, that impacts gameplay, not just the UI. It's acceptable here because with enemies and pollution disabled, armor resistances and pollution have no significant gameplay effects.

Avoiding "armor"#

Armor is a core concept in Factorio and due to later armors supporting equipment like personal roboports and exoskeletons, they are very useful even without combat. But "armor" sounds military, so I wanted to name it something different. I figured this change was out-of-scope for Pacifist, so I made my own small mod BackpackRename that refers to armor instead as "backpacks". (After making this mod, I noticed another mod used the term "utility vest" which could have also worked.) Making my own mod also meant that I could avoid promising support for other mods, as many mods add additional armors, and I didn't want to try list out all of them.

Future posts#

Today I focused on changing the in-game text, the next couple weeks I'll talk about other changes I made to Pacifist, adjusting some sprites and hiding some military-related items from some places they were still visible and could be referenced even though the actual entities couldn't be made.

  1. Yes, the title of this blog post is a Hamlet reference


Have something to add? Post a comment by sending an email to comments@aweirdimagination.net. You may use Markdown for formatting.

There are no comments yet.