MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 1 | SYNOPSIS |
Zesstra | b6ac9f6 | 2020-01-21 11:11:16 +0100 | [diff] [blame] | 2 | int save_object(string name [, int format]) |
| 3 | string save_object([int format]) |
MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 4 | |
Zesstra | 715ec20 | 2025-07-09 22:18:31 +0200 | [diff] [blame^] | 5 | DESCRIPTION |
| 6 | Encode the saveable variables of the current object into a string. |
MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 7 | |
Zesstra | 715ec20 | 2025-07-09 22:18:31 +0200 | [diff] [blame^] | 8 | 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 User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 14 | |
Zesstra | 715ec20 | 2025-07-09 22:18:31 +0200 | [diff] [blame^] | 15 | In the second form the string is returned directly. If the |
| 16 | object is destructed, the result is 0. |
MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 17 | |
Zesstra | 715ec20 | 2025-07-09 22:18:31 +0200 | [diff] [blame^] | 18 | In both forms, the optional <format> argument determines the |
| 19 | format of the savefile to be written: |
MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 20 | |
Zesstra | 715ec20 | 2025-07-09 22:18:31 +0200 | [diff] [blame^] | 21 | -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 User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 29 | |
Zesstra | 715ec20 | 2025-07-09 22:18:31 +0200 | [diff] [blame^] | 30 | It is recommended to use version 3 or higher. |
MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 31 | |
Zesstra | 715ec20 | 2025-07-09 22:18:31 +0200 | [diff] [blame^] | 32 | 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 | |
| 37 | HISTORY |
| 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 | |
| 46 | SEE ALSO |
Zesstra | b6ac9f6 | 2020-01-21 11:11:16 +0100 | [diff] [blame] | 47 | restore_object(E), save_value(E) |