-
What do you want to achieve? I want to set a variable to be equal to one value if it exists (even if it’s false), or another value as a default backup.
-
What is the issue? Using the
or
keyword in variable declarations will use the second value if the first is equal tofalse
.
local rotClamp = shakeParams["RotationClamp"] or Config.SHAKE_ROTATION_CLAMP_DEFAULT
In this example, when shakeParams[“RotationClamp”] == false, the default is set instead (currently true)
I don’t want to run this code for every variable, as it’s long and hard to read
local rotClamp, cameraMotionBlurEnabled, cameraMotionBlurMax, uiMotionBlurEnabled
if shakeParams["RotationClamp"] == nil then
rotClamp = Config.SHAKE_ROTATION_CLAMP_DEFAULT
else
rotClamp = shakeParams["RotationClamp"]
end
(… on and on for each variable)
- What solutions have you tried so far? I’ve looked for anyone trying to achieve a similar functionality, but haven’t found anything.
Thanks!