Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- * globals * -- (used by read_ini and delete_ini)
- local iniFilename = 'config.ini'
- local iniFile = io.open(iniFilename, 'r')
- -- * retrieves game settings from config.ini + sets conditions | values appropriately! * --
- function read_ini()
- -- * locals * --
- local r_fullscreen = getObject('Scenes[Options_Menu].SceneConditions[fullscreen?]')
- local r_subtitles = getObject('Scenes[Options_Menu].SceneConditions[subtitles?]')
- local r_resolution = getObject('Scenes[Options_Menu].SceneValues[resolution?]')
- local r_language = getObject('Scenes[Options_Menu].SceneValues[language?]')
- -- * script * --
- if iniFile then
- local line = iniFile:read()
- print(iniFilename .. ' exists!')
- print('retrieving settings from ' .. iniFilename .. '!')
- for line in io.lines(iniFilename) do
- -- * begin if else * --
- if line == 'Fullscreen = No' then
- r_fullscreen:setValue(VConditionValue, false)
- print('fullscreen mode is off!')
- else
- if line == 'Fullscreen = Yes' then
- r_fullscreen:setValue(VConditionValue, true)
- print('fullscreen mode is on!')
- end end
- -- * --
- if line == 'Resolution = Auto' then
- r_resolution:setValue(VValueInt, 0)
- print('resolution is set to auto!')
- else
- if line == 'Resolution = 1920x1080' then
- r_resolution:setValue(VValueInt, 4)
- print('resolution is currently set at 1920x1080!')
- else
- if line == 'Resolution = 1680x1050' then
- r_resolution:setValue(VValueInt, 3)
- print('resolution is currently set at 1680x1050!')
- else
- if line == 'Resolution = 1280x1024' then
- r_resolution:setValue(VValueInt, 2)
- print('resolution is currently set at 1280x1024!')
- else
- if line == 'Resolution = 1024x768' then
- r_resolution:setValue(VValueInt, 1)
- print('resolution is currently set at 1024x768!')
- end end end end end
- -- * --
- if line == 'Subtitles = No' then
- r_subtitles:setValue(VConditionValue, false)
- print('subtitles are currently set to off!')
- else
- if line == 'Subtitles = Yes' then
- r_subtitles:setValue(VConditionValue, true)
- print('subtitles are currently set to on!')
- end end
- -- * --
- if line == 'Language = English' then
- r_language:setValue(VValueInt, 0)
- print('Language is currently set to English!')
- else
- if line == 'Language = German' then
- r_language:setValue(VValueInt, 1)
- print('Language is currently set to German!')
- else
- if line == 'Language = Spanish' then
- r_language:setValue(VValueInt, 2)
- print('Language is currently set to Spanish!')
- end end end
- -- * --
- end
- iniFile:close()
- print('successfully retrieved settings from ' .. iniFilename .. '!')
- -- * end if else * --
- else
- print(iniFilename .. ' does not exist!')
- end
- end
- -- * removes the config.ini file so we can replace it with the temporary file! (only called if we have edited any of the settings) * --
- function delete_ini()
- if iniFile then
- os.remove(iniFilename)
- else
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement