file = [[
[/Script/Engine.GameUserSettings]
bUseDesiredScreenHeight=False

[/Script/CodaGame.CodaUserSettings]
GraphicsOptions=(OptionName=INVTEXT("Post Process Quality"),SettingDisplayTexts=(INVTEXT("Low"),INVTEXT("Medium"),INVTEXT("High"),INVTEXT("Epic")),CurrentQaulity=3,QaulityRedirection=(0,1,2,3),ScalabilityGroup="PostProcessQuality",ApplicableConsoleVariables=("r.AmbientOcclusionMipLevelFactor","r.AmbientOcclusionMaxQuality","r.AmbientOcclusionLevels","r.AmbientOcclusionRadiusScale","r.GTAO.Numangles","r.RenderTargetPoolMin","r.LensFlareQuality","r.SceneColorFringeQuality","r.EyeAdaptationQuality","r.BloomQuality","r.FastBlurThreshold","r.Upscale.Quality","r.LightShaftQuality","r.Filter.SizeScale","r.Tonemapper.Quality","r.Tonemapper.GrainQuantization"))
GraphicsOptions=(OptionName=INVTEXT("Anti Aliasing"),SettingDisplayTexts=(INVTEXT("None"),INVTEXT("FXAA"),INVTEXT("Fast TXAA"),INVTEXT("TXAA")),CurrentQaulity=2,QaulityRedirection=(-2,-1,0,2),ScalabilityGroup="AntiAliasingQuality",ApplicableConsoleVariables=("r.PostProcessAAQuality","r.TemporalAA.R11G11B10History"))
GraphicsOptions=(OptionName=INVTEXT("Screen Space Reflections"),SettingDisplayTexts=(INVTEXT("Off"),INVTEXT("High"),INVTEXT("Epic")),CurrentQaulity=0,QaulityRedirection=(0,2,3),ScalabilityGroup="EffectsQuality",ApplicableConsoleVariables=("r.SSR.Quality","r.SSR.HalfResSceneColor"))
GraphicsOptions=(OptionName=INVTEXT("Depth of Field"),SettingDisplayTexts=(INVTEXT("Off"),INVTEXT("Medium"),INVTEXT("High"),INVTEXT("Epic")),CurrentQaulity=1,QaulityRedirection=(0,1,2,3),ScalabilityGroup="PostProcessQuality",ApplicableConsoleVariables=("r.DepthOfFieldQuality","r.DOF.Gather.AccumulatorQuality","r.DOF.Gather.PostfilterMethod","r.DOF.Gather.EnableBokehSettings","r.DOF.Gather.RingCount","r.DOF.Scatter.ForegroundCompositing","r.DOF.Scatter.BackgroundCompositing","r.DOF.Scatter.EnableBokehSettings","r.DOF.Scatter.MaxSpriteRatio","r.DOF.Recombine.Quality","r.DOF.Recombine.EnableBokehSettings","r.DOF.TemporalAAQuality","r.DOF.Kernel.MaxForegroundRadius","r.DOF.Kernel.MaxBackgroundRadius"))
GraphicsOptions=(OptionName=INVTEXT("Motion Blur"),SettingDisplayTexts=(INVTEXT("Off"),INVTEXT("Medium"),INVTEXT("Epic")),CurrentQaulity=1,QaulityRedirection=(0,1,3),ScalabilityGroup="PostProcessQuality",ApplicableConsoleVariables=("r.MotionBlurQuality"))
GraphicsOptions=(OptionName=INVTEXT("Shadow Quality"),SettingDisplayTexts=(INVTEXT("Low"),INVTEXT("Medium"),INVTEXT("High"),INVTEXT("Epic")),CurrentQaulity=1,QaulityRedirection=(0,1,2,3),ScalabilityGroup="ShadowQuality",ApplicableConsoleVariables=("r.LightFunctionQuality","r.ShadowQuality","r.Shadow.CSM.MaxCascades","r.Shadow.MaxResolution","r.Shadow.MaxCSMResolution","r.Shadow.RadiusThreshold","r.Shadow.DistanceScale","r.Shadow.CSM.TransitionScale","r.Shadow.PreShadowResolutionFactor","r.Shadow.CacheWPOPrimitives","r.DistanceFieldShadowing","r.DistanceFieldAO","r.AOQuality","r.CapsuleShadows"))
GraphicsOptions=(OptionName=INVTEXT("Volumetric Fog"),SettingDisplayTexts=(INVTEXT("Low"),INVTEXT("Medium"),INVTEXT("High"),INVTEXT("Epic")),CurrentQaulity=1,QaulityRedirection=(0,1,2,3),ScalabilityGroup="ShadowQuality",ApplicableConsoleVariables=("r.VolumetricFog","r.VolumetricFog.GridPixelSize","r.VolumetricFog.GridSizeZ","r.VolumetricFog.HistoryMissSupersampleCount","r.VolumetricFog.Jitter","r.VolumetricFog.LightIntensity","r.VolumetricFog.DistanceScale"))
GraphicsOptions=(OptionName=INVTEXT("Number of Shadows"),SettingDisplayTexts=(INVTEXT("Low"),INVTEXT("High"),INVTEXT("Epic")),CurrentQaulity=0,QaulityRedirection=(0,2,3),ScalabilityGroup="ShadowQuality",ApplicableConsoleVariables=("r.DynamicShadowDetailMode","fx.Niagara.ParticleShadows"))
GraphicsOptions=(OptionName=INVTEXT("World Detail"),SettingDisplayTexts=(INVTEXT("Low"),INVTEXT("High"),INVTEXT("Epic")),CurrentQaulity=0,QaulityRedirection=(0,2,3),ScalabilityGroup="EffectsQuality",ApplicableConsoleVariables=("r.DetailMode"))
GraphicsOptions=(OptionName=INVTEXT("View Distance"),SettingDisplayTexts=(INVTEXT("Low"),INVTEXT("Medium"),INVTEXT("High"),INVTEXT("Epic")),CurrentQaulity=1,QaulityRedirection=(0,1,2,3),ScalabilityGroup="ViewDistanceQuality",ApplicableConsoleVariables=("r.SkeletalMeshLODBias","r.ViewDistanceScale","r.LightMaxDrawDistanceScale","r.StaticMeshLODDistanceScale"))
GraphicsOptions=(OptionName=INVTEXT("Textures"),SettingDisplayTexts=(INVTEXT("Low"),INVTEXT("Medium"),INVTEXT("High"),INVTEXT("Epic")),CurrentQaulity=1,QaulityRedirection=(0,1,2,3),ScalabilityGroup="TextureQuality",ApplicableConsoleVariables=("r.Streaming.MipBias","r.Streaming.AmortizeCPUToGPUCopy","r.Streaming.MaxNumTexturesToStreamPerFrame","r.Streaming.Boost","r.MaxAnisotropy","r.VT.MaxAnisotropy","r.Streaming.LimitPoolSizeToVRAM","r.Streaming.PoolSize","r.Streaming.MaxEffectiveScreenSize","r.Streaming.UIStreamingBias","r.Streaming.NiagaraStreamingBias"))
GraphicsOptions=(OptionName=INVTEXT("Effects"),SettingDisplayTexts=(INVTEXT("Low"),INVTEXT("Medium"),INVTEXT("High"),INVTEXT("Epic")),CurrentQaulity=3,QaulityRedirection=(0,1,2,3),ScalabilityGroup="EffectsQuality",ApplicableConsoleVariables=("r.TranslucencyLightingVolumeDim","r.RefractionQuality","r.SceneColorFormat","r.TranslucencyVolumeBlur","r.SkyAtmosphere.AerialPerspectiveLUT.FastApplyOnOpaque","r.SkyAtmosphere.AerialPerspectiveLUT.SampleCountMaxPerSlice","r.SkyAtmosphere.AerialPerspectiveLUT.DepthResolution","r.SkyAtmosphere.FastSkyLUT","r.SkyAtmosphere.FastSkyLUT.SampleCountMin","r.SkyAtmosphere.FastSkyLUT.SampleCountMax","r.SkyAtmosphere.SampleCountMin","r.SkyAtmosphere.SampleCountMax","r.SkyAtmosphere.TransmittanceLUT.UseSmallFormat","r.SkyAtmosphere.TransmittanceLUT.SampleCount","r.SkyAtmosphere.MultiScatteringLUT.SampleCount","fx.Niagara.QualityLevel","r.SeparateTranslucencyAutoDownsample","r.SeparateTranslucencyScreenPercentage","r.SSS.Scale","r.SSS.SampleSet","r.SSS.Quality","r.SSS.HalfRes","r.ReflectionCaptureResolution","r.ParticleLightQuality","r.EmitterSpawnRateScale","r.MaterialQualityLevel"))
GraphicsOptions=(OptionName=INVTEXT("Foliage"),SettingDisplayTexts=(INVTEXT("Low"),INVTEXT("Medium"),INVTEXT("High"),INVTEXT("Epic")),CurrentQaulity=5,QaulityRedirection=(0,1,2,3),ScalabilityGroup="FoliageQuality",ApplicableConsoleVariables=("foliage.DensityScale","grass.DensityScale"))
bGotoHeroOnAutoHeroCycleV2=False
bEnableCloudSaveEnumeration=True
bGotoHeroOnPlayerHeroCycleV2=True
bDevSuppressEnemyTurnOverlay=False
bDevSkipMissionValidation=True
VolumeSettings=(BusName="MasterVolume",Volume=100.000000)
VolumeSettings=(BusName="MasterMusicVolume",Volume=100.000000)
VolumeSettings=(BusName="MasterVoiceVolume",Volume=100.000000)
VolumeSettings=(BusName="SFXMasterVolume",Volume=100.000000)
KOVoiceoverFrequency=100.000000
bAccessibleSubtitles=False
VisCameraSchemeV2=EDefaultVisCam
TacticsCameraSchemeV2=EDrivableTacticsCam
bUseGLDevPool=False
GraphicsOptionsVersion=13
bDevSuppressMissionIntros=False
bInvertCameraVertical=False
bInvertCameraHorizontal=False
CameraTurnRateMultiplier_KBM_v2=1.500000
CameraTurnRateMultiplier_Gamepad=0.800000
bShowDevControls=False
bDevLogAssetLoadingDependencies=False
bDevLogAssetLoadingTemplateList=False
ScalingType=DLSS
DLSSQualityMode=Quality
FSRQualityMode=UltraQuality
StaticResQuality=Balanced
DynamicResQuality=Performance
bEnableRTXShadows=False
bEnableRTXAO=True
bEnableRTXReflections=True
CameraShakeIntensity=1.000000
bUseVSync=False
bUseDynamicResolution=False
ResolutionSizeX=1280
ResolutionSizeY=720
LastUserConfirmedResolutionSizeX=1280
LastUserConfirmedResolutionSizeY=720
WindowPosX=-1
WindowPosY=-1
FullscreenMode=2
LastConfirmedFullscreenMode=2
PreferredFullscreenMode=1
Version=5
AudioQualityLevel=0
LastConfirmedAudioQualityLevel=0
FrameRateLimit=120.000000
DesiredScreenWidth=1280
DesiredScreenHeight=720
LastUserConfirmedDesiredScreenWidth=1280
LastUserConfirmedDesiredScreenHeight=720
LastRecommendedScreenWidth=-1.000000
LastRecommendedScreenHeight=-1.000000
LastCPUBenchmarkResult=257.810760
LastGPUBenchmarkResult=310.568909
LastCPUBenchmarkSteps=243.285614
LastCPUBenchmarkSteps=267.494202
LastGPUBenchmarkSteps=520.718689
LastGPUBenchmarkSteps=213.797714
LastGPUBenchmarkSteps=350.855286
LastGPUBenchmarkSteps=314.291534
LastGPUBenchmarkSteps=94.899673
LastGPUBenchmarkSteps=363.382660
LastGPUBenchmarkSteps=923.744446
LastGPUBenchmarkMultiplier=1.000000
bUseHDRDisplayOutput=False
ColorBlindCorrectionMode=0
ColorBlindWorldAlpha=0.000000
ColorBlindUIAlpha=0.000000
ScreenShotFormat=3
MAXFPSWhenUnlimited=200.000000

[RayTracing]
r.RayTracing.EnableInGame=True

[ScalabilityGroups]
sg.ResolutionQuality=100.000000
sg.ViewDistanceQuality=3
sg.AntiAliasingQuality=3
sg.ShadowQuality=3
sg.PostProcessQuality=3
sg.TextureQuality=3
sg.EffectsQuality=3
sg.FoliageQuality=3
sg.ShadingQuality=3

[ShaderPipelineCache.CacheFile]
LastOpened=CodaGame
]]

t = {
  ['Anti Aliasing']='11',
  ['Post Process Quality']='22',
  ['Foliage']='66',
  ['Textures']='55',
  ['View Distance']='99',
  ['World Detail']='88',
  ['Effects']='77',
  ['Screen Space Reflections']='9',
  ['Shadow Quality']='33',
  ['Volumetric Fog']='44',
  ['Number of Shadows']='55',
}

-- Replace and escape () brackets magic characters with %( and %). This confuses Lua's patterns.
file_esc = string.gsub(file, '(%()', '%%(')
file_esc = string.gsub(file_esc, '(%))', '%%)')


for k,v in pairs(t) do
  -- Pattern .- matches first occurance of any characters until CurrentQaulity (narrow), whereas
  --  .* will match to the last occurance of CurrentQaulity (wide)
  pattern = k .. '\".-CurrentQaulity=%d'
  
  -- Extract the substring content 
  --  ex. Foliage"%),SettingDisplayTexts=%(INVTEXT%("Low"%),INVTEXT%("Medium"%),INVTEXT%("High"%),INVTEXT%("Epic"%)%),CurrentQaulity=5
  substr = string.match(file_esc, pattern)
  -- print(substr)

  -- Replace the value and remove magic escape characters
  newsubstr = string.gsub(substr, '%d', v)
  newsubstr = string.gsub(newsubstr, '%%', '')
  -- print(newsubstr)

  -- Replace the old substr with the newsubstr inside original file.
  --  file = string.gsub(file, pattern, newsubstr) accomplishes the same thing because pattern can find the substr.
  file = string.gsub(file, substr, newsubstr)
end

print(file)
 

Lua online compiler

Write, Run & Share Lua code online using OneCompiler's Lua online compiler for free. It's one of the robust, feature-rich online compilers for Lua language, running the latest Lua version 5.4. Getting started with the OneCompiler's Lua editor is easy and fast. The editor shows sample boilerplate code when you choose language as Lua and start coding.

Taking inputs (stdin)

OneCompiler's Lua online editor supports stdin and users can give inputs to programs using the STDIN textbox under the I/O tab. Following is a sample Lua program which takes name as input and prints hello message with your name.

name = io.read("*a")
print ("Hello ", name)

About Lua

Lua is a light weight embeddable scripting language which is built on top of C. It is used in almost all kind of applications like games, web applications, mobile applications, image processing etc. It's a very powerful, fast, easy to learn, open-source scripting language.

Syntax help

Variables

  • By default all the variables declared are global variables
  • If the variables are explicitly mentioned as local then they are local variables.
  • Lua is a dynamically typed language and hence only the values will have types not the variables.

Examples

-- global variables
a = 10

-- local variables

local x = 30
Value TypeDescription
numberRepresents numbers
stringRepresents text
nilDifferentiates values whether it has data or not
booleanValue can be either true or false
functionRepresents a sub-routine
userdataRepresents arbitary C data
threadRepresents independent threads of execution.
tableCan hold any value except nil

Loops

1. While:

While is also used to iterate a set of statements based on a condition. Usually while is preferred when number of iterations are not known in advance.

while(condition)
do
--code
end

2. Repeat-Until:

Repeat-Until is also used to iterate a set of statements based on a condition. It is very similar to Do-While, it is mostly used when you need to execute the statements atleast once.

repeat
   --code
until( condition )

3. For:

For loop is used to iterate a set of statements based on a condition.

for init,max/min value, increment
do
   --code
end

Functions

Function is a sub-routine which contains set of statements. Usually functions are written when multiple calls are required to same set of statements which increase re-usuability and modularity.

optional_function_scope function function_name( argument1, argument2, argument3........, argumentn)
--code
return params with comma seperated
end