Getting Localised Names As a String

Place to get help with not working mods / modding interface.
ratchetfreak
Filter Inserter
Filter Inserter
Posts: 952
Joined: Sat May 23, 2015 12:10 pm
Contact:

Re: Getting Localised Names As a String

Post by ratchetfreak »

coopmaster wrote: After working with my mod (Galactic Trade) with multiplayer, I was able to get it to where each person could have a different search term that is saved. This is able to be done without desync even though each person has a different search term. I do this by having a table for anything that changes for each player. What I do is have something like this:

Code: Select all

global.gt_current_search_term[event.player_index]
All the clients are able to have their own search terms without causing desync. So lets say that we did have access to the localisation, then it wouldn't really change since the only thing that my mod would be changed by the localisation is the results it shows. What results it shows doesn't affect anyone else, therefore no desync. This is why I'm confused, I don't have to have all the same code run on all the clients from my testing. I don't really know what causes desync since I got desync when they were changing the variable when it wasn't a table. When one client tried to initialize the variable that caused desync and now when I make it a table it doesn't. My guess is that it sends what people type into the textbox to everyone. If that's the case, it can do the same thing for localised text. All it would have to do is send the text to other players to stay synced. I don't know how it works, but my mod somehow works like this and I think that if I am able to have every person have a different search term based on a text box only visible to the client. I think that whatever happens to make this possible, that it could work if they do it for localised strings. I would like to hear how it works though.
Because all clients will have a copy of that table.

But calls to create guis for other players will be made but won't have a visible effect. The (dummy) objects still get made and click events will also get called but setting text is a noop on the other clients.

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

Re: Getting Localised Names As a String

Post by Rseding91 »

coopmaster wrote:
ratchetfreak wrote:
coopmaster wrote:
ratchetfreak wrote:
Outsider wrote:I'm aware that the engine only uses the actual translated text when rendering the gui, because i was desperate enough to load all the items localised names in labels in a hidden frame then tried looping through them and getting the caption values, obviously ended up with just references :)

I know i probably sound stupid at this point but i still don't understand what would be the issue of providing access to the localised strings using an extra index in the get localised names functions, or even a different function entirely?

Is it the fact that all data sent from the engine through the api has to be the same on all clients?
There's 2 issues really; one is that there is no way to tell factorio "this call only affects 1 client's gui it's okay to not run it on the other clients"

The other is that localization isn't held to the same "must be equal" standard as the other files (I think). Which means that to let the mod access localization then either the player shouldn't be allowed to connect if the localization he uses doesn't match the ones the other players have or that localization needs to be shared across players. (there's also a similar issue with replays).
After working with multiplayer a bit, I still honestly don't completely understand how it works. If the host does most of the calculations for the clients (like if game.get_player(2).whatever is done by the host) then I can understand why this won't be a thing. If there are some calculations that are done by the client, then I think that it could work since if it is saved as a variable, it would work since it would be saved as a string.

All mod code is executed by all the clients and the host and each time it's executed it must have the exact same effect; otherwise desync.
After working with my mod (Galactic Trade) with multiplayer, I was able to get it to where each person could have a different search term that is saved. This is able to be done without desync even though each person has a different search term. I do this by having a table for anything that changes for each player. What I do is have something like this:

Code: Select all

global.gt_current_search_term[event.player_index]
All the clients are able to have their own search terms without causing desync. So lets say that we did have access to the localisation, then it wouldn't really change since the only thing that my mod would be changed by the localisation is the results it shows. What results it shows doesn't affect anyone else, therefore no desync. This is why I'm confused, I don't have to have all the same code run on all the clients from my testing. I don't really know what causes desync since I got desync when they were changing the variable when it wasn't a table. When one client tried to initialize the variable that caused desync and now when I make it a table it doesn't. My guess is that it sends what people type into the textbox to everyone. If that's the case, it can do the same thing for localised text. All it would have to do is send the text to other players to stay synced. I don't know how it works, but my mod somehow works like this and I think that if I am able to have every person have a different search term based on a text box only visible to the client. I think that whatever happens to make this possible, that it could work if they do it for localised strings. I would like to hear how it works though.
There is no client. There is no server. There are only peers - peers running the full simulation of all connected players with all combined input actions per player.
If you want to get ahold of me I'm almost always on Discord.

Outsider
Fast Inserter
Fast Inserter
Posts: 115
Joined: Sat Jan 10, 2015 12:23 am
Contact:

Re: Getting Localised Names As a String

Post by Outsider »

Rseding91 wrote: There is no client. There is no server. There are only peers - peers running the full simulation of all connected players with all combined input actions per player.
wow i had no idea factorio uses a p2p model for multiplayer.. i was always under the impression it uses client/server with the host being the server..

makes so much sense now why different data would cause a desync, Thanks for explaining guys.
Advanced Logistics System - Provides a detailed view of your logistics network and the items within it

User avatar
L0771
Filter Inserter
Filter Inserter
Posts: 516
Joined: Tue Jan 14, 2014 1:51 pm
Contact:

Re: Getting Localised Names As a String

Post by L0771 »

if you want only search, can make a table with ["item-name"] = Item name for every lenguage
en:
leng =
{ en = { ["iron-ore"] = "Iron ore" },
es_ES = { ["iron-ore"] = "Mena de hierro" }
fr = ...}

or ["Iron ore"] = "iron-ore" ...
but, you must save every name.

ratchetfreak
Filter Inserter
Filter Inserter
Posts: 952
Joined: Sat May 23, 2015 12:10 pm
Contact:

Re: Getting Localised Names As a String

Post by ratchetfreak »

L0771 wrote:if you want only search, can make a table with ["item-name"] = Item name for every lenguage
en:
leng =
{ en = { ["iron-ore"] = "Iron ore" },
es_ES = { ["iron-ore"] = "Mena de hierro" }
fr = ...}

or ["Iron ore"] = "iron-ore" ...
but, you must save every name.
a.k.a. duplicate the localization files into your mod

Outsider
Fast Inserter
Fast Inserter
Posts: 115
Joined: Sat Jan 10, 2015 12:23 am
Contact:

Re: Getting Localised Names As a String

Post by Outsider »

L0771 wrote:if you want only search, can make a table with ["item-name"] = Item name for every lenguage
en:
leng =
{ en = { ["iron-ore"] = "Iron ore" },
es_ES = { ["iron-ore"] = "Mena de hierro" }
fr = ...}

or ["Iron ore"] = "iron-ore" ...
but, you must save every name.
Yeah i thought about doing that but it's really impractical when you have to support mods that add new entities.. you'd have to include every possible translation file for each mod you support.
Advanced Logistics System - Provides a detailed view of your logistics network and the items within it

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

Re: Getting Localised Names As a String

Post by Rseding91 »

Outsider wrote:
Rseding91 wrote: There is no client. There is no server. There are only peers - peers running the full simulation of all connected players with all combined input actions per player.
wow i had no idea factorio uses a p2p model for multiplayer.. i was always under the impression it uses client/server with the host being the server..

makes so much sense now why different data would cause a desync, Thanks for explaining guys.
The "Headless Server" does cause confusion with it's name :\
If you want to get ahold of me I'm almost always on Discord.

Post Reply

Return to “Modding help”