Sliders to control various volumes?

  • #10, by NigecWednesday, 10. October 2012, 16:12 13 years ago
    Fantastic job! thank you smile

    Key Killer

    640 Posts


  • #11, by afrlmeWednesday, 10. October 2012, 16:48 13 years ago
    I'm seeing if I can figure out how to include the config ini thing into it but trying to understand roughly translated german into english is errr - well whatever razz

    Bing translator is doing a pretty good job nonetheless mind! (if you read between he lines razz

    ----- http://www.visionaire-studio.net/forum/thread/config-ini/ ----- Sethos: I take before the appropriate settings in the my game options menu. The or the buttons light up as active. The buttons are linked to this end values or conditions. Then, I'm writing this in the config.ini. This is not a problem everything but...

    If I now reboot the game, the settings are transferred though, but in my menu, the appropriately enabled buttons no longer shine. The player can not see, how everything is set.

    Example (config.ini):

    
    local iniFilename = localAppDir .. 'config.ini'
    local iniFile = io.open(iniFilename, 'r')
    local newIniFilename = localAppDir .. 'config.ini.bak'
    local newIniFile = io.open(newIniFilename, 'w')

    print(iniFilename) print(newIniFilename) local fullscreen = getObject('Conditions[Vollbildmodus]'):getBool(VConditionValue) local subtitles = getObject('Conditions[Untertitel]'):getBool(VConditionValue) local resolution = getObject('Values[resolution]'):getStr(VValueString) local hotspots = getObject('Conditions[Hotspots]'):getBool(VConditionValue) if iniFile ~= nil then print('ini file exists') for line in iniFile:lines() do print(line) local lineLowercase = line:lower() if not string.find(lineLowercase, 'fullscreen') and not string.find(lineLowercase, 'resolution') and not string.find(lineLowercase, 'subtitles') and not string.find(lineLowercase, 'hotspots') then newIniFile:write(line .. '\n') end end iniFile:close() end

    if fullscreen then newIniFile:write('Fullscreen = Yes\n') else newIniFile:write('Fullscreen = No\n') end

    if subtitles then newIniFile:write('Subtitles = Yes\n') else newIniFile:write('Subtitles = No\n') end

    if hotspots then newIniFile:write('Hotspots = Yes\n') else newIniFile:write('Hotspots = No\n') end

    newIniFile:write('Resolution = ' .. resolution .. '\n')

    newIniFile:close()

    os.remove(iniFilename) os.rename(newIniFilename, iniFilename)

    So, I have the following problem. How can I translate the entries of the "config.ini" at the start of the game again in conditions or values, so that at the start of the game all changes in the option menu will appear again?

    1 Scene: Options menu after the entries have been made: (check attachments) 2 Scene: Options menu after the restart of the game: (check attachments)

    mowren:

    To use the conditions you need to read the config.ini course. To do this, you can also run a loop after opening the file and locate the content for each row. Then found a setting you set the condition or the value that you are responsible for viewing with setValue.

    Sethos:

    Hello mowren,

    I've imagined already so that. My question would be now but as I practically implementing that. Unfortunately, I'm not too versed in LUA. Write for the config itself I have used already, eternities...

    config.ini: (current config.ini of my project with the associated "Switch is active" "Conditions")

    Resolution = 1600 x 900 condition "_schalter3_aktiv" Fullscreen = no condition "_schalter5_aktiv" 3D effects = Yes condition "_schalter6_aktiv" Surround = no condition "_schalter7_aktiv" Language = German condition "_schalter8_aktiv" Subtitles = Yes condition "_schalter9_aktiv" Hotspots = no condition "_schalter10_aktiv" MusicVolume = 30 SoundVolume = 60 SpeechVolume = 90

    An example of the Ausführungscript you can me based on row 1 and 2 of my config to the read and type of translation of the corresponding condition?

    mowren: This is in the much almost the you same what with the write do. Only with queries against the contents of the row. VConditionValue set for Boolean value, VValueInt for integer such as the volume.

    
    local loc_fullscreen = getObject('Conditions[_schalter5_aktiv]'):getBool(VConditionValue)

    if iniFile ~= nil then for line in iniFile:lines() do local lineLowercase = line:lower() if lineLowercase == "fullscreen = no" then loc_fullscreen:setValue(VConditionValue, false) elseif lineLowercase == XY then ... end end iniFile:close() end

    Sethos: Thank you for your quick help. Had to fight quite well...

    Imperator

    7286 Posts

  • #12, by EinzelkämpferWednesday, 10. October 2012, 21:27 13 years ago
    I don't think you need to understand the discussion between Sethos and mowren, so don't waste too much time on understanding it.

    Sethos wrote the first script that writes several condition values into the config.ini. The condition values of course can be manipulated by the user through an options menu. Then Sethos asks on how to read the config.ini, so that he is able to initialise his in-game condition values on game start. mowren delivers sample code to read the lines in the file.

    As I said before - I haven't tried this, but the code looks promising.

    Newbie

    81 Posts

  • #13, by afrlmeWednesday, 10. October 2012, 23:05 13 years ago
    yeah if it works based on the conversation ...

    the conversation is somewhat needed as they are explaining what it is, does & the issues.

    the full code put together & an example project file would most definitely help matters razz

    Imperator

    7286 Posts

  • #14, by afrlmeFriday, 12. October 2012, 17:22 13 years ago
    hmmm ... the first script I've added just to my project just to see what it would do & I added a blank config.ini file to the project directory & added the needed conditions & values to the options menu area ...

    for some reason it writes the music, speech, sfx values to the ini file - even though I see nothing about it reading or writing the values for them in the script!?

    when I close & reopen the project the audio values in the ini file are reflected via your sound control script - again without anything in the script to do with it ...

    but nothing else is writing to the ini file.

    for instance I created conditions "subtitles? (value=true)", "fullscreen? (value=true)", "language? (value=English)", "resolution? (value=1920x1080)" but nothing was added to the config.ini other than sound volumes.

    Imperator

    7286 Posts