Nucleus handler tools โบ Docs โบ Context โบ ModifySaveFile
Context.ModifySaveFile
Open in the workbench (search, and try it in a handler)
Context.ModifySaveFile(
installSavePath: string,
saveFullPath: string,
type: Nucleus.SaveType,
info: Nucleus.SaveInfo
): boolean
Edits keys in an INI/CFG file. Example: Context.ModifySaveFile(path, path, Nucleus.SaveType.INI, [new Nucleus.IniSaveInfo("Section", "Key", "Value")]);
installSavePath: Full path of the source file to read. For INI it is copied to saveFullPath first when the two paths differ (the copy fails if saveFullPath already exists).saveFullPath: Full path where the edited file is written; may be the same as installSavePath to edit in place.type: File format: Nucleus.SaveType.INI or Nucleus.SaveType.CFG (Source-engine style cfg); any other value throws.info: One or more entries to set, new Nucleus.IniSaveInfo(section, key, value) for INI or new Nucleus.CfgSaveInfo(section, key, value) for CFG; other kinds are ignored.
In practice
For INI files Nucleus writes each Nucleus.IniSaveInfo key into the file (copying it from the first path to the second first, when they differ); for CFG files each Nucleus.CfgSaveInfo; other entries are skipped. Handlers call it in Game.Play, mostly with the same path twice, to set each instance's resolution and window mode in the game's INI file; above all in Unreal Engine games.
Is "In practice" right?
๐ค People: no votes yet
๐ค AIs: no votes yet
Score 0: peopleโs ๐ minus ๐ (AIs never count).
Tell us what's wrongGive feedback
By engine: rarer in Source games.
Example
var ini =
Context.GetFolder(Nucleus.Folder.InstancedGameFolder) +
"\\Settings.ini";
Context.ModifySaveFile(ini, ini, Nucleus.SaveType.INI, [
new Nucleus.IniSaveInfo("Display", "Width", Context.Width),
new Nucleus.IniSaveInfo(
"Display",
"Height",
Context.Height
),
new Nucleus.IniSaveInfo("Display", "Fullscreen", "0")
]);
Is the doc right?
๐ค People: no votes yet
๐ค AIs: no votes yet
Score 0: peopleโs ๐ minus ๐ (AIs never count).
Tell us what's wrongGive feedback