Config.ini script

  • #30, by afrlmeTuesday, 26. May 2015, 15:35 9 years ago
    Ah sorry then, I don't really know what to tell you. It is recommended to manually read the file & update the settings yourself as only the volume settings are read & updated automatically, even though some of the settings such as fullscreen, resolution, resizeable, language & data etc are supposedly read automatically by the engine.

    The config.ini script I wrote was just one example, & quite a complex one at that. The script itself & the parameters don't have to be so complicated. You don't even have to add the #comment lines to the config.ini file, as this (below) would also be perfectly acceptable...
    file = data.vis
    fullscreen = yes
    resolution = auto
    resizeable = yes
    language = English
    

    the audio parameters would get added & updated automatically.

    Imperator

    7278 Posts


  • #31, by LebosteinTuesday, 26. May 2015, 16:16 9 years ago
    If you use this ini file from your last example, the language is not set correctly. You see the english strings but the value game.StandardLanguage is not updated to "English". Try this simple ved-example:

    https://dl.dropboxusercontent.com/u/13472834/visionaire/lang...

    If you start normal, you see on the screen "Ein Text in deutscher Sprache" and the message.log shows:
    16:31:58: german (18,0)
    16:31:58: ---Empty---


    If you start with language = english in config.ini, you see on the screen "A text in english language" and the message.log shows:
    16:34:42: german (18,0)
    16:34:42: ---Empty---

    The message output is generated with
    print(game.StandardLanguage)
    print(game.SpeechLanguage)
    

    Key Killer

    621 Posts

  • #32, by afrlmeTuesday, 26. May 2015, 21:16 9 years ago
    Yeah, very very strange.

    Could you try this please...
    -- * local variables * --
    local fn = "config.ini" -- store filename
    
    -- * function used to read data from the config.ini file * --
    function read_ini()
     local fr = io.open(localAppDir .. fn, "r") -- read from config.ini
     -- * --
     if fr then -- if file exists then...
      lines = fr:read() -- read currently selected line
      for lines in io.lines(localAppDir .. fn) do -- iterate through lines in config.ini
       line = string.lower(lines) -- convert all line content to lowercase
       if not line:find("#") then -- skip all lines containing "#"
        if line == "language = english" then game:setValue(VGameStandardLanguage, Languages["English"]); print("language is currently set to " .. game:getLink(VGameStandardLanguage):getName()) end
        if line == "language = german" then game:setValue(VGameStandardLanguage, Languages["German"]); print("language is currently set to " .. game:getLink(VGameStandardLanguage):getName()) end
       end
      end
      fr:close()
      print("successfully retrieved settings from " .. fn)
     end
    end
    


    1. add script above as a definition script.
    2. to call it: add an execute a script action part to the game launch actions containing...
    read_ini()
    


    The thing is though that language is not automatically updated in the config.ini file. So even if player changes language while playing, it will only be the save game files that remember the language used.

    Imperator

    7278 Posts

  • #33, by LebosteinWednesday, 27. May 2015, 05:42 9 years ago
    In my eyes, the game.StandardLanguage is only a parameter that stores the language that should be used if no other language is set (respectively the main language of the game). To overwrite the game.StandardLanguage to change the language at the beginning of the game seems a dirty hack. There must be an other hidden parameter for storing the current language I think (game.CurrentLanguage?). The LANGUAGE parameter in the config.ini seems to modify this game.CurrentLanguage parameter only. The game.StandardLanguage remains untouched - a clean way in my eyes. This would also explain the above behavior in my test game.

    Key Killer

    621 Posts

  • #34, by afrlmeWednesday, 27. May 2015, 12:57 9 years ago
    game.CurrentLanguage?

    game.StandardLanguage is the current language. It controls the current language being used for both texts & speech - the latter only if game.SpeechLanguage returns empty.

    What happens if you change the language to English at beginning of game with the change language action parts & then try printing the game.StandardLanguage? Does it still return German or does it now return English?

    Imperator

    7278 Posts