fluffos/docs/efun/objects/save_object.md

38 lines
1.1 KiB
Markdown
Raw Permalink Normal View History

2018-12-30 16:43:04 -08:00
---
title: objects / save_object
---
2023-11-25 09:50:24 -08:00
# save_object
2018-12-30 16:43:04 -08:00
### NAME
2018-12-30 16:59:01 -08:00
save_object() - save the values of variables in an object into a file
2018-12-30 16:43:04 -08:00
### SYNOPSIS
2018-12-30 16:59:01 -08:00
int save_object( string name, int flag );
docs/efun: document FFI + dwlib efuns, fix return-type errors, drop stale docs Reviewed every efun doc against the .spec source of truth (the make_func declarations) and the implementations. New docs for 28 previously-undocumented efuns: - package_ffi (18): new docs/efun/ffi/ category — ffi_load/unload/symbol/ prepare/call, alloc/free/sizeof/peek/address/read/write, struct_layout, callback/callback_addr/callback_free, error/status. - package_dwlib (10, under contrib/): add_a, vowel, replace, replace_dollars/html/mxp/objects, roulette_wheel, query_multiple_short, reference_allowed. Return-type fixes where the doc contradicted the spec/impl (mostly stale MudOS behavior): cache_stats/debugmalloc/dump_file_descriptors/ malloc_status/mud_status return string; disable_commands/flush_messages/ receive/set_heart_beat are void; get_char/input_to/link/set_eval_limit return int; call_stack -> mixed *, function_profile -> mapping *. Also corrected receive's and disable_commands' stale "returns ..." prose. Expanded implode (function-fold form) and save_object (save-to-string form), both of which the docs had omitted. Removed 4 stale docs for efuns that no longer exist (no spec entry, no f_ implementation, zero references anywhere): errorp, opcprof, swap, dump_socket_status. Regenerated the affected efun index pages. The Docusaurus build passes with onBrokenLinks:throw, confirming no dangling links. Note: the docs/zh-CN translated tree still mirrors the old English docs (same stale entries, and it lacks the new efuns); left for a separate translation pass. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-08 16:03:27 -07:00
string save_object( int flag );
2018-12-30 16:43:04 -08:00
### DESCRIPTION
2018-12-30 16:59:01 -08:00
2018-12-30 16:43:04 -08:00
Save all values of non-static variables in this object in the file
'name'. valid_write() in the master object determines whether this is
allowed. The optional second argument is a bitfield: If bit 0 is 1,
then variables that are zero (0) are also saved (normally, they
aren't). Object variables always save as 0. If bit 1 is 1, then the
save file will be compressed.
docs/efun: document FFI + dwlib efuns, fix return-type errors, drop stale docs Reviewed every efun doc against the .spec source of truth (the make_func declarations) and the implementations. New docs for 28 previously-undocumented efuns: - package_ffi (18): new docs/efun/ffi/ category — ffi_load/unload/symbol/ prepare/call, alloc/free/sizeof/peek/address/read/write, struct_layout, callback/callback_addr/callback_free, error/status. - package_dwlib (10, under contrib/): add_a, vowel, replace, replace_dollars/html/mxp/objects, roulette_wheel, query_multiple_short, reference_allowed. Return-type fixes where the doc contradicted the spec/impl (mostly stale MudOS behavior): cache_stats/debugmalloc/dump_file_descriptors/ malloc_status/mud_status return string; disable_commands/flush_messages/ receive/set_heart_beat are void; get_char/input_to/link/set_eval_limit return int; call_stack -> mixed *, function_profile -> mapping *. Also corrected receive's and disable_commands' stale "returns ..." prose. Expanded implode (function-fold form) and save_object (save-to-string form), both of which the docs had omitted. Removed 4 stale docs for efuns that no longer exist (no spec entry, no f_ implementation, zero references anywhere): errorp, opcprof, swap, dump_socket_status. Regenerated the affected efun index pages. The Docusaurus build passes with onBrokenLinks:throw, confirming no dangling links. Note: the docs/zh-CN translated tree still mirrors the old English docs (same stale entries, and it lacks the new efuns); left for a separate translation pass. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-08 16:03:27 -07:00
If no file name is given (the argument is omitted or is the integer
flag bitfield), the serialized data is not written to disk but is
returned as a string instead, suitable for use with the string form of
restore_object().
2018-12-30 16:43:04 -08:00
### RETURN VALUE
docs/efun: document FFI + dwlib efuns, fix return-type errors, drop stale docs Reviewed every efun doc against the .spec source of truth (the make_func declarations) and the implementations. New docs for 28 previously-undocumented efuns: - package_ffi (18): new docs/efun/ffi/ category — ffi_load/unload/symbol/ prepare/call, alloc/free/sizeof/peek/address/read/write, struct_layout, callback/callback_addr/callback_free, error/status. - package_dwlib (10, under contrib/): add_a, vowel, replace, replace_dollars/html/mxp/objects, roulette_wheel, query_multiple_short, reference_allowed. Return-type fixes where the doc contradicted the spec/impl (mostly stale MudOS behavior): cache_stats/debugmalloc/dump_file_descriptors/ malloc_status/mud_status return string; disable_commands/flush_messages/ receive/set_heart_beat are void; get_char/input_to/link/set_eval_limit return int; call_stack -> mixed *, function_profile -> mapping *. Also corrected receive's and disable_commands' stale "returns ..." prose. Expanded implode (function-fold form) and save_object (save-to-string form), both of which the docs had omitted. Removed 4 stale docs for efuns that no longer exist (no spec entry, no f_ implementation, zero references anywhere): errorp, opcprof, swap, dump_socket_status. Regenerated the affected efun index pages. The Docusaurus build passes with onBrokenLinks:throw, confirming no dangling links. Note: the docs/zh-CN translated tree still mirrors the old English docs (same stale entries, and it lacks the new efuns); left for a separate translation pass. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-08 16:03:27 -07:00
With a file name, save_object() returns 1 for success, 0 for failure.
In the no-file-name form it returns the save data as a string.
2018-12-30 16:43:04 -08:00
### SEE ALSO
2018-12-30 16:59:01 -08:00
restore_object(3)