blob: cb17764b7d102de1dacb28e7160c661aa42f73b0 [file] [log] [blame]
MG Mud User88f12472016-06-24 23:31:02 +02001SYNOPSIS
Zesstrab6ac9f62020-01-21 11:11:16 +01002 int save_object(string name [, int format])
3 string save_object([int format])
MG Mud User88f12472016-06-24 23:31:02 +02004
Zesstra715ec202025-07-09 22:18:31 +02005DESCRIPTION
6 Encode the saveable variables of the current object into a string.
MG Mud User88f12472016-06-24 23:31:02 +02007
Zesstra715ec202025-07-09 22:18:31 +02008 In the first form, the string is written to the file <name>.
9 A suffix ".c" will be stripped from the name, the suffix ".o"
10 may be added by the master object during the check in
11 valid_read(). Result is 0 if the save file could be created,
12 and non-zero on a non-fatal error (file could not be written,
13 or current object is destructed).
MG Mud User88f12472016-06-24 23:31:02 +020014
Zesstra715ec202025-07-09 22:18:31 +020015 In the second form the string is returned directly. If the
16 object is destructed, the result is 0.
MG Mud User88f12472016-06-24 23:31:02 +020017
Zesstra715ec202025-07-09 22:18:31 +020018 In both forms, the optional <format> argument determines the
19 format of the savefile to be written:
MG Mud User88f12472016-06-24 23:31:02 +020020
Zesstra715ec202025-07-09 22:18:31 +020021 -1: use the driver's native format (default).
22 0: original format, used by Amylaar LPMud and LDMud <= 3.2.8 .
23 1: LDMud >= 3.2.9: non-lambda closures, symbols, quoted arrays
24 can be saved.
25 2: LDMud >= 3.5.0: floats are stored in a different way, which is
26 more compact and can store the new float losslessly.
27 3: LDMud >= 3.5.0: can also save lvalues references (without it,
28 the plain rvalue will be saved).
MG Mud User88f12472016-06-24 23:31:02 +020029
Zesstra715ec202025-07-09 22:18:31 +020030 It is recommended to use version 3 or higher.
MG Mud User88f12472016-06-24 23:31:02 +020031
Zesstra715ec202025-07-09 22:18:31 +020032 A variable is considered 'saveable' if it is not declared
33 as 'nosave' or 'static'.
34
35 Only lfuns bound to the current object can be saved.
36
37HISTORY
38 Since LDMud 3.2.8, save_object() returns a success value.
39 The direct encoding into a string was added in LDMud 3.2.8, but
40 may be moved into a different efun in future.
41 LDMud 3.2.9 added the saving of non-lambda closures, symbols,
42 and quoted arrays, using the new savefile format version 1.
43 LDMud 3.2.10 added the <format> argument.
44 LDMud 3.5.0 added savefile format version 2 and 3.
45
46SEE ALSO
Zesstrab6ac9f62020-01-21 11:11:16 +010047 restore_object(E), save_value(E)