A method to detect changes in player language in Singleplayer.

Place to ask discuss and request the modding support of Factorio. Don't request mods here.
Post Reply
User avatar
Smart Inserter
Smart Inserter
Posts: 5078
Joined: Tue Jul 12, 2016 9:03 am

A method to detect changes in player language in Singleplayer.

Post by eradicator »

The Problem

When a player loads a savegame in English, then saves, changes to German and reloads the savegame the only event raised is on_load. In multiplayer this is not a problem because of on_player_left_game and on_player_joined_game.

A Solution

Just to be clear: I do NOT want information about what locale a player has. I just want to know IF it changed or not.

I do not care how exactly this is implemented. During observations I noticed that sometimes on_configuration_changed is raised with ConfigurationChangedData that is just a bunch of empty tables. That would be sufficent. Raising on_player_left/joined in Singleplayer would also be sufficent (let them both happen right after on_load or something). A seperate event for this would work too but that seems like a sledgehammer method?


Because I'm dealing with LuaPlayer.request_translation so I need to know when the locale changed.
Author of: Belt Planner, Hand Crank Generator, Screenshot Maker, /sudo and more.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.

Post Reply

Return to “Modding interface requests”