Menus in The Witcher 3/Scripting

It's fairly easy to access menu variables in Witcher Script using the CInGameConfigWrapper class, accessed using the static global object. Keep in mind that the game uses strings to store values using these methods, so you must convert to string first.

var igconfig : CInGameConfigWrapper; var myValue : float;

igconfig = theGame.GetInGameConfigWrapper;

//getting a value myValue = StringToFloat(igconfig.GetVarValue('MYGROUP', 'MYVAR'));

//setting a value igconfig.SetVarValue('MYGROUP', 'MYVAR', FloatToString(1.0f));

Loading Default Values
On first load, the values in the menu are not set to anything (all values are NULL, interpreted as  or 0). You can check for this and make sure that proper defaults are loaded in, instead of relying on a user to hit a preset button. Here is an example check (with a version number, so that can upgrade from previous versions easily).


 * Required entry in XML for version variable

if (!theGame.GetInGameConfigWrapper.GetVarValue('EnhancedTargeting', 'ETVersion')) { 	theGame.GetInGameConfigWrapper.SetVarValue('EnhancedTargeting', 'ETEnabled', true); theGame.GetInGameConfigWrapper.SetVarValue('EnhancedTargeting', 'ETCameraWeight', FloatToString(1.0f)); theGame.GetInGameConfigWrapper.SetVarValue('EnhancedTargeting', 'ETMovementWeight', FloatToString(0.75f)); theGame.GetInGameConfigWrapper.SetVarValue('EnhancedTargeting', 'ETFacingWeight', FloatToString(0.0f)); theGame.GetInGameConfigWrapper.SetVarValue('EnhancedTargeting', 'ETHysteresis', FloatToString(1.1f)); theGame.GetInGameConfigWrapper.SetVarValue('EnhancedTargeting', 'ETInFrameCheck', false); theGame.GetInGameConfigWrapper.SetVarValue('EnhancedTargeting', 'ETSignsTowardsCamera', true); theGame.GetInGameConfigWrapper.SetVarValue('EnhancedTargeting', 'ETDisableCameraLock', true); theGame.GetInGameConfigWrapper.SetVarValue( 'EnhancedTargeting', 'ETVersion', "2.0"); } else if (StringToFloat(theGame.GetInGameConfigWrapper.GetVarValue('EnhancedTargeting', 'ETVersion')) < 2.0) { 	theGame.GetInGameConfigWrapper.SetVarValue('EnhancedTargeting', 'ETVersion', "2.0"); }

To save options set with scripts to user.settings, use CR4Game method import final function SaveUserSettings; Example: theGame.SaveUserSettings; Together with adding option for it, it can be used for loading default options only once at the first start of the mod instead of reloading them each time. Or for storing another data for your mod in user.settings.