beetlebug▾
/

ztk::game load

Gives the save of a name over a dict of defaults.

ztk::game load NAME ?DEFAULT?

Description

Gives DEFAULT with each key of the save put over it, so a key that an older save lacks keeps its default. A name with no save, or a file that is not a save, gives DEFAULT, or an empty dict. The text of the file is read as a list, and never as a script.

Returns

A dict.

Examples

% ztk::game save prefs {sound 0}
> ztk::game load prefs {sound 1 music 1}
sound 0 music 1

% ztk::game load nothing {best 0}
best 0

Errors

% ztk::game load ..
bad save name "..": must be 1 to 64 characters of a-z, 0-9, _, and -
-errorcode ZTK GAME SAVE NAME

% ztk::game load best {a}
missing value to go with key
-errorcode TCL VALUE DICTIONARY

Facts

Capability
None.
Tcl release
Tcl 9.1 and 8.6.
Since
ztk 1.0.0-beta.7

See also