Filtering on_string_translated

Place to ask discuss and request the modding support of Factorio. Don't request mods here.
Post Reply
User avatar
Deadlock989
Smart Inserter
Smart Inserter
Posts: 2528
Joined: Fri Nov 06, 2015 7:41 pm

Filtering on_string_translated

Post by Deadlock989 »

Would it be possible to get some way of filtering this event - if it returned a unique id that you could optionally pass through request_translation(), or just the id of the mod that called it?

At the moment, because the event fires in all mods when any single mod calls request_translation(), you have to keep track of what you asked to be translated in a big table in the meantime, or you'll be taking actions on things that other mods wanted translating and you didn't. Presumably every mod has to do this, so that could be a lot of variable space in the end. If I could just do something like this, it would be easier and mess up the global table less:

Code: Select all

script.on_event(defines.events.on_string_translated, function(event)
	if event.translated and event.calling_mod == MY_MOD_ID then
		...
	end
end)
Image

Helfima
Fast Inserter
Fast Inserter
Posts: 199
Joined: Tue Jun 28, 2016 11:40 am
Contact:

Re: Filtering on_string_translated

Post by Helfima »

yes it's a problem, we need a filter on mod or uuid to reduce the mod execution when is not necessary, that can reduce desync/disconnect problem in multi-player when we have a lot of translate string request.

if you can get local tag (en,fr ect..) that can save space in global table.
for example with Pyanadon mod pack, my mod need save +1700 translate string and that by user, it's not good in multi-player.
currently it is not very realistic, if we have a game of 100 players we are 1700x100 translated string
or with the local tag that can be 1700x3 if there are en,fr,ru users

Rseding91
Factorio Staff
Factorio Staff
Posts: 13209
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: Filtering on_string_translated

Post by Rseding91 »

Helfima wrote:
Tue Feb 18, 2020 11:48 am
yes it's a problem, we need a filter on mod or uuid to reduce the mod execution when is not necessary, that can reduce desync/disconnect problem in multi-player when we have a lot of translate string request.

if you can get local tag (en,fr ect..) that can save space in global table.
for example with Pyanadon mod pack, my mod need save +1700 translate string and that by user, it's not good in multi-player.
currently it is not very realistic, if we have a game of 100 players we are 1700x100 translated string
or with the local tag that can be 1700x3 if there are en,fr,ru users
You're never going to desync players with this logic. If you're doing that; then that's just bad mod code and not related to translations.

As for the translation count; that's also never going to change. Welcome to translations and locale - it only ever gets worse with time. 170,000 strings for translations is nothing compared to the data that the game processes each tick when you would have 100 connected players. Either you do it, and it works, or you don't :P It's just the nature of how translations work.
If you want to get ahold of me I'm almost always on Discord.

Helfima
Fast Inserter
Fast Inserter
Posts: 199
Joined: Tue Jun 28, 2016 11:40 am
Contact:

Re: Filtering on_string_translated

Post by Helfima »

well, if 1700x100 against 1700x3 stored in global data does not create a problem in MP I trust you.

in short, let's say that if we can reduce the execution of mods on big mod packs it's always good to win, especially when someone have slow machines.

but the filter to know what mod sent request is better, for example me I store the tranlated string of entity and I don't need the request for item that a another mod request.

NB:
on my mod, I did a loop analysis work to reduce the computation time, I placed a large part in init and on_change_configuration but some are necessarily in game. it is difficult to debug a script and I ended up cutting out the phases (as translation request) on few ticks and the return of my users was great. the users, when they are a disconnect, because there are a problem on the computation time, say me "desync", for us it's the same. I do not know if the translation request can pose disconnect on large numbers, especially if several mod interprets the event. it's just a feeling of the feedback from my mod users.
on the other hand I had a crash feedback generated by another mod than mine, on the translation requests of my mod :)

User avatar
Deadlock989
Smart Inserter
Smart Inserter
Posts: 2528
Joined: Fri Nov 06, 2015 7:41 pm

Re: Filtering on_string_translated

Post by Deadlock989 »

To repeat the original request without digressions about desyncs - would it be possible to have a filter for this event by the caller's mod name? Or even not an actual filter but just that parameter passed in with the data?
Image

User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 5206
Joined: Tue Jul 12, 2016 9:03 am
Contact:

Re: Filtering on_string_translated

Post by eradicator »

Deadlock989 wrote:
Thu Feb 27, 2020 11:00 am
To repeat the original request without digressions about desyncs - would it be possible to have a filter for this event by the caller's mod name? Or even not an actual filter but just that parameter passed in with the data?
Generally +1. I'd even be fine if the filter was hardcoded and the event never raised for things requested by other mods.
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.

User avatar
Therenas
Factorio Staff
Factorio Staff
Posts: 232
Joined: Tue Dec 11, 2018 2:10 pm
Contact:

Re: Filtering on_string_translated

Post by Therenas »

Having events filtered by mod would be useful in other places too, GUI mainly as you almost never care about other people's GUI events. It wouldn't have the same performance impact as this does, but if such a system were put in place, it could be applied to other events too.

Post Reply

Return to “Modding interface requests”