Hi, I finally decided not to give up and look for a way to translate the platform name.
After almost two hours, I managed to write a working version. It works as I described above - it renames the platform based on the language of the player who created the world.
Now the code just needs to pass your review, as you clearly have more experience, and you'll be able to tell at a glance whether there are any flaws in my code.
Here's the code from the \TFMG\scripts\init.lua file.
--Upon player joins
script.on_event(defines.events.on_player_created, function(e)
local player = game.players[e.player_index]
if e.player_index == 1 then --request translation of the platform name
player.request_translation({"item-name.constructron"})
end
storage.players[player.index] = {}--initialise player storage
if settings.global["start-as-SELF"].value then
player.teleport({ x = 0, y = 0 }, storage.platform.surface.name)
player.enter_space_platform (storage.platform)
end
local group = game.permissions.get_group("players")
if group then
group.add_player(player)
end
end)
script.on_event(defines.events.on_force_created,
function()
supercomputer.make_the_prod_bar_show() --updating the prod for newly created forces and such.
end
)
--localization of the platform name
script.on_event(defines.events.on_string_translated, function(e)
if e.translated and e.localised_string[1] == "item-name.constructron" then
for _, platform in pairs(game.forces["player"].platforms) do
if platform.name == "SELF" then
platform.name = e.result
break
end
end
end
end)
"item-name.constructron" Taken purely for testing.
Thank you for your time.