Saving and language [SOLVED]

  • #10, by gabartsSaturday, 10. November 2018, 10:25 5 years ago
    Yes it works because I have also 2 flags for language switch in main menu and those control the changes after the game is started. The splash screen is only for start. Of course the Lua code to check config.ini would be the cleaner solution but I need a programmer for that smile

    Forum Fan

    137 Posts


  • #11, by afrlmeSaturday, 10. November 2018, 10:56 5 years ago
    Did you check the script index section on the wiki? I shared my read/write config.ini script on there a couple or so years back. It obviously needs editing to fit your own project, but it's a nice template that you can learn how to read from/write to any any external files.

    Imperator

    7278 Posts

  • #12, by esmeraldaTuesday, 13. November 2018, 12:57 5 years ago
    I have a similar problem and I don't get how you solved this.

    I have a menu to start the game where you can pick the language. When playing you can go back to the menu, change the language and resume playing - no problem so far.
    But I want the player to have the possibility to start a new game, when he was already playing - in the language he chooses then. (meaning : playing a game in language A, deciding to try it in language B fresh from the start)
    So when I execute an autosave at the beginning of the game it saves the language picked first. 
    As far as I understood, this was the same problem you had @gabarts. How did you solve this?
    Writing/Reading the config.ini won't help, because I want the player to pick the language, not save his first pick at a language. Using two autosaves won't do either, because the player will have only one autosave (in the language he picked first)

    Edit: oh, with an extra splashscreen where you pick the language. Not really what I wanted. Does anybody have an idea for a different solution?

    Key Killer

    513 Posts

  • #13, by afrlmeTuesday, 13. November 2018, 16:43 5 years ago
    The language stored in the save file is irrelevant. Just read the config.ini again after loading from a savegame file & update the language to what's inside of the config.ini.

    You can use this event handler to listen out for when the engine loads a save game, then you can call the read_config.ini function from inside of the script or if you aren't using a config.ini script then you could write/read just the language to a different external file.

    function onEngineEvent(event, path) 
        if event == "LoadingSavegameSuccess" then 
            --print(path)
            read_config() -- read config.ini (need to replace with relevant function)
        end 
    end 
    registerEventHandler("engineEvent", "onEngineEvent")

    Imperator

    7278 Posts

  • #14, by esmeraldaTuesday, 13. November 2018, 17:17 5 years ago
    Ah, now I get it. You need to update(write in) the config.ini each time you change the language and when loading a savegame read the config.ini and use the stored language information - right?
    Ok, I wil have to take a look at your write-config.ini-script and see if I understand how to use it. Or better just the writing in an external file... (but that may be too much hussle for the little jam-game, so maybe in a future project)
    Thank you!

    Key Killer

    513 Posts

  • #15, by afrlmeTuesday, 13. November 2018, 20:35 5 years ago
    Aye, Visionaire doesn't automatically write/read data from the config.ini - only volume levels for some reason. Everything else needs to be done manually, though some will get read on game launch automatically (such as language, window mode, resolution, etc).

    All require you to manually update/overwrite the config.ini with the new data when you change something.

    Imperator

    7278 Posts