config.ini loads partially , preferences don't affect anything

  • #1, by sebastianMonday, 13. July 2015, 19:43 9 years ago
    Hello guys,

    im trying to do a typical scenario with a config.ini file: changing fullscreen to window mode (with specific resolution in window mode) and some other options like music,sound,speech volume.
    I tried to follow the steps discribed by AFRLme in the wiki, trimmed the shown lua script down to the values in need and tested the preferences out.
    For me to understand the script first i focused on the "read_ini()" stuff.
    I implemented the read_ini() function in the start script as an execute script action part at the very first position.

    When starting the game via Visionaire (directly run the game, not a builded game), i can see in the log (via "print log")
    the first lines printed by the read_ini() function:

    print(fn .. " exists")
    print("loading data from " .. fn)
    


    after that the whole stuff regarding resolution is skipped and the next lines are handling the music-volume:

    if line:find("musicvolume =") then print("music volume = " .. getVolume(eMusicVolume)) end
    if line:find("soundvolume =") then print("sound volume = " .. getVolume(eSoundVolume)) end
    if line:find("speechvolume =") then print("speech volume = " .. getVolume(eSpeechVolume)) end
    


    The volume showing up in the game is not the values i set in the config.ini but some kind of default(?) values...

    I don't know what i made wrong here. It seems to just doesn't set some config.ini-stuff correctly when i change e.g. Fullscreen = No and Resolution = 1280x720. I expected now that when i start the game form the editor via F9 that it starts in 1280x720 window mode. instead its fullscreen , auto.


    Maybe is it because of the "settings" done for the Player in Visionaire which override the config.ini from the game?

    Here is the lua-script i used so far:

    --[[
    Read/Write Config.ini [v2] (02/03/2014)
    Written by AFRLme [Lee Clarke]
    -- + --
    alternatingfrequencies@hotmail.com | skype @ AFRLme
    -- + --
    This script is donation optional. In game credit is non-negotiable.
    You are free to: ¹ use it in your game(s). ² modify the script.
    Do not remove - or edit - this comment block.
    --]]
     
    -- * local variables * --
    local fn = "config.ini" -- store filename
    -- * --
    local wm = getObject("Conditions[cfg_wm]") -- window mode [fullscreen/windowed]
    local res = getObject("Values[cfg_res]") -- resolution [fullscreen mode only]
     
    -- * fallback * --
    local lglvl = "Error" -- default value for log level
    local df = "Data.vis" -- filename should reflect exported .vis file
    game:setValue(VGameSpeechLanguage, game:getLink(VGameStandardLanguage)) -- default speech language to stndard language
     
    -- * tables * --
    local t_res = {"Auto","Desktop","1280x720"} -- add available resolutions here
    local t_lang = game:getLinks(VGameLanguages) -- store all available languages into a table
     
    -- * 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
      print(fn .. " exists")
      print("loading data from " .. fn)
      for lines in io.lines(localAppDir .. fn) do
       line = string.lower(lines) -- convert all line content to lowercase
       if not line:find("#") then -- skip all lines containing "#"
        if line:find("file =") then df = string.sub(lines, 8); print("file is currently linked to " .. df) end
        -- * window mode * --
        if line == "fullscreen = no" then wm:setValue(VConditionValue, false); print("window mode is currently set to Windowed") end
        if line == "fullscreen = yes" then wm:setValue(VConditionValue, true); print("window mode is currently set to Fullscreen") end
        -- * resolution * --
        for i = 1, table.maxn(t_res) do if line == ("resolution = " .. string.lower( t_res[i] )) then res:setValue(VValueString, t_res[i]); res:setValue(VValueInt, i); print("resolution is currently set to " .. res:getStr(VValueString)) end end
        
        -- * log level * --
        if line == "loglevel = error" then lglvl = "Error"; print("log level is currently set to Error") end
        if line == "loglevel = warning" then lglvl = "Warning"; print("log level is currently set to Warning") end
        if line == "loglevel = info" then lglvl = "Info"; print("log level is currently set to Info") end
        -- * sound levels * --
        if line:find("musicvolume =") then print("music volume = " .. getVolume(eMusicVolume)) end
        if line:find("soundvolume =") then print("sound volume = " .. getVolume(eSoundVolume)) end
        if line:find("speechvolume =") then print("speech volume = " .. getVolume(eSpeechVolume)) end
        
       end
      end
      fr:close()
      print("successfully retrieved settings from " .. fn)
     else
      print(fn  .. " does not exist")
     end
    end
    


    config.ini looks like this:

    File = mysuperawesomegame.ved
    # Fullscreen = {Yes|No}
    # Yes - starts the game in fullscreen
    # No - starts the game in a window
    Fullscreen = No
    #
    # Resolution = {Auto|Desktop|Custom}
    # Auto - wide-screen support is activated if a wide-screen display is detected
    # Desktop - current desktop resolution is used when game is started in full screen mode
    # Custom - enter a custom value eg: Resolution = 1920x1080
    Resolution = Auto
    #
    # LogLevel = {Info|Warning|Error}
    LogLevel = Info
    #
    # MusicVolume|SoundVolume|SpeechVolume = int value {0-100}
    MusicVolume = 80
    SoundVolume = 80
    SpeechVolume = 100
    


    As i said it only contains the read_ini() function yet, but thats what i only do right now.

    print log shows this:
    http://cl.ly/image/1v070W3c2X3w/Image%202015-07-13%20at%207.41.16%20nachm..png
    (also the log is cutted on the bottom but this seems to be another bug ^^)


    Hope someone can help me out here smile confuse


    kind regards
    Sebastian

    Thread Captain

    2346 Posts


  • #2, by sebastianMonday, 13. July 2015, 19:46 9 years ago
    PS: i know cfg_res is missing in the values table here, but im curious because it isnt needed for the fullscreen/window mode stuff...

    Thread Captain

    2346 Posts

  • #3, by afrlmeMonday, 13. July 2015, 20:25 9 years ago
    check the actual messages.log file. To find out where your messages.log file & config.ini are being saved launch the game via the editor. Press TAB on keyboard to open developer console & type:
    exec print( localAppDir )
    

    press enter, then type PRINT LOG & look for a path along the lines of: c:/users/... & that will be where the logs, save game files & your config.ini will go.

    I want to know what errors are listed in the log. & quick note: the config.ini script could do with updating to the new shorthand Lua script code.

    P.S: when the console log is cut off like that it's usually because you are not running the game at the intended resolution of the game. It's some kind of bug. The amount cut off depends seems to depend on surface resolution & the default font used.

    Imperator

    7278 Posts

  • #4, by sebastianMonday, 13. July 2015, 20:35 9 years ago
    So to be correct the config.ini which is besides the .ved file is the file which gets used when "packing the game/using when building the game" and the one at the path i get there is used for "in editor usage"?

    Found the path. It only contained the .ini file and only the music-stuff was in it... i think i can update it to the correct settings i want to have and see what it brings, right?

    thanks so far.

    Thread Captain

    2346 Posts

  • #5, by sebastianMonday, 13. July 2015, 20:43 9 years ago
    PPPPS: do the devs know about the console-cut-off-bug? Its really annoying to work with it right now

    Thread Captain

    2346 Posts

  • #6, by afrlmeMonday, 13. July 2015, 20:52 9 years ago
    I probably mentioned it to them. Actually what I'm wanting is for them to implement a floating window with an auto-updating log that listens out for new messages or updates every x seconds. I suppose I could probably write a tool myself with python or something for that, but I'm feeling lazy! grin

    The config.ini that gets created inside of the target folder when exporting / compiling your game into an executable is actually just a basic config.ini that gets read from on the initial launch of the game. The official location will be in the c:/users... folder because it allows players to delete your game but retain the settings & save games unlike previously as they would have been included in the actual game folder instead.

    So, you need to create the config.ini inside of the c:/users... folder location for the script to work.

    Imperator

    7278 Posts