|
414 | 414 | <return type="bool" />
|
415 | 415 | <param index="0" name="value" type="int" />
|
416 | 416 | <description>
|
417 |
| - Stores an integer as 8 bits in the file. This advances the file cursor by 1 byte. |
| 417 | + Stores an integer as 8 bits in the file. This advances the file cursor by 1 byte. Returns [code]true[/code] if the operation is successful. |
418 | 418 | [b]Note:[/b] The [param value] should lie in the interval [code][0, 255][/code]. Any other value will overflow and wrap around.
|
419 | 419 | [b]Note:[/b] If an error occurs, the resulting value of the file position indicator is indeterminate.
|
420 | 420 | To store a signed integer, use [method store_64], or convert it manually (see [method store_16] for an example).
|
|
424 | 424 | <return type="bool" />
|
425 | 425 | <param index="0" name="value" type="int" />
|
426 | 426 | <description>
|
427 |
| - Stores an integer as 16 bits in the file. This advances the file cursor by 2 bytes. |
| 427 | + Stores an integer as 16 bits in the file. This advances the file cursor by 2 bytes. Returns [code]true[/code] if the operation is successful. |
428 | 428 | [b]Note:[/b] The [param value] should lie in the interval [code][0, 2^16 - 1][/code]. Any other value will overflow and wrap around.
|
429 | 429 | [b]Note:[/b] If an error occurs, the resulting value of the file position indicator is indeterminate.
|
430 | 430 | To store a signed integer, use [method store_64] or store a signed integer from the interval [code][-2^15, 2^15 - 1][/code] (i.e. keeping one bit for the signedness) and compute its sign manually when reading. For example:
|
|
466 | 466 | <return type="bool" />
|
467 | 467 | <param index="0" name="value" type="int" />
|
468 | 468 | <description>
|
469 |
| - Stores an integer as 32 bits in the file. This advances the file cursor by 4 bytes. |
| 469 | + Stores an integer as 32 bits in the file. This advances the file cursor by 4 bytes. Returns [code]true[/code] if the operation is successful. |
470 | 470 | [b]Note:[/b] The [param value] should lie in the interval [code][0, 2^32 - 1][/code]. Any other value will overflow and wrap around.
|
471 | 471 | [b]Note:[/b] If an error occurs, the resulting value of the file position indicator is indeterminate.
|
472 | 472 | To store a signed integer, use [method store_64], or convert it manually (see [method store_16] for an example).
|
|
476 | 476 | <return type="bool" />
|
477 | 477 | <param index="0" name="value" type="int" />
|
478 | 478 | <description>
|
479 |
| - Stores an integer as 64 bits in the file. This advances the file cursor by 8 bytes. |
| 479 | + Stores an integer as 64 bits in the file. This advances the file cursor by 8 bytes. Returns [code]true[/code] if the operation is successful. |
480 | 480 | [b]Note:[/b] The [param value] must lie in the interval [code][-2^63, 2^63 - 1][/code] (i.e. be a valid [int] value).
|
481 | 481 | [b]Note:[/b] If an error occurs, the resulting value of the file position indicator is indeterminate.
|
482 | 482 | </description>
|
|
485 | 485 | <return type="bool" />
|
486 | 486 | <param index="0" name="buffer" type="PackedByteArray" />
|
487 | 487 | <description>
|
488 |
| - Stores the given array of bytes in the file. This advances the file cursor by the number of bytes written. |
| 488 | + Stores the given array of bytes in the file. This advances the file cursor by the number of bytes written. Returns [code]true[/code] if the operation is successful. |
489 | 489 | [b]Note:[/b] If an error occurs, the resulting value of the file position indicator is indeterminate.
|
490 | 490 | </description>
|
491 | 491 | </method>
|
|
495 | 495 | <param index="1" name="delim" type="String" default="","" />
|
496 | 496 | <description>
|
497 | 497 | Store the given [PackedStringArray] in the file as a line formatted in the CSV (Comma-Separated Values) format. You can pass a different delimiter [param delim] to use other than the default [code]","[/code] (comma). This delimiter must be one-character long.
|
498 |
| - Text will be encoded as UTF-8. |
| 498 | + Text will be encoded as UTF-8. Returns [code]true[/code] if the operation is successful. |
499 | 499 | [b]Note:[/b] If an error occurs, the resulting value of the file position indicator is indeterminate.
|
500 | 500 | </description>
|
501 | 501 | </method>
|
502 | 502 | <method name="store_double">
|
503 | 503 | <return type="bool" />
|
504 | 504 | <param index="0" name="value" type="float" />
|
505 | 505 | <description>
|
506 |
| - Stores a floating-point number as 64 bits in the file. This advances the file cursor by 8 bytes. |
| 506 | + Stores a floating-point number as 64 bits in the file. This advances the file cursor by 8 bytes. Returns [code]true[/code] if the operation is successful. |
507 | 507 | [b]Note:[/b] If an error occurs, the resulting value of the file position indicator is indeterminate.
|
508 | 508 | </description>
|
509 | 509 | </method>
|
510 | 510 | <method name="store_float">
|
511 | 511 | <return type="bool" />
|
512 | 512 | <param index="0" name="value" type="float" />
|
513 | 513 | <description>
|
514 |
| - Stores a floating-point number as 32 bits in the file. This advances the file cursor by 4 bytes. |
| 514 | + Stores a floating-point number as 32 bits in the file. This advances the file cursor by 4 bytes. Returns [code]true[/code] if the operation is successful. |
515 | 515 | [b]Note:[/b] If an error occurs, the resulting value of the file position indicator is indeterminate.
|
516 | 516 | </description>
|
517 | 517 | </method>
|
518 | 518 | <method name="store_half">
|
519 | 519 | <return type="bool" />
|
520 | 520 | <param index="0" name="value" type="float" />
|
521 | 521 | <description>
|
522 |
| - Stores a half-precision floating-point number as 16 bits in the file. This advances the file cursor by 2 bytes. |
| 522 | + Stores a half-precision floating-point number as 16 bits in the file. This advances the file cursor by 2 bytes. Returns [code]true[/code] if the operation is successful. |
523 | 523 | [b]Note:[/b] If an error occurs, the resulting value of the file position indicator is indeterminate.
|
524 | 524 | </description>
|
525 | 525 | </method>
|
526 | 526 | <method name="store_line">
|
527 | 527 | <return type="bool" />
|
528 | 528 | <param index="0" name="line" type="String" />
|
529 | 529 | <description>
|
530 |
| - Stores [param line] in the file followed by a newline character ([code]\n[/code]), encoding the text as UTF-8. This advances the file cursor by the length of the line, after the newline character. The amount of bytes written depends on the UTF-8 encoded bytes, which may be different from [method String.length] which counts the number of UTF-32 codepoints. |
| 530 | + Stores [param line] in the file followed by a newline character ([code]\n[/code]), encoding the text as UTF-8. This advances the file cursor by the length of the line, after the newline character. The amount of bytes written depends on the UTF-8 encoded bytes, which may be different from [method String.length] which counts the number of UTF-32 codepoints. Returns [code]true[/code] if the operation is successful. |
531 | 531 | [b]Note:[/b] If an error occurs, the resulting value of the file position indicator is indeterminate.
|
532 | 532 | </description>
|
533 | 533 | </method>
|
534 | 534 | <method name="store_pascal_string">
|
535 | 535 | <return type="bool" />
|
536 | 536 | <param index="0" name="string" type="String" />
|
537 | 537 | <description>
|
538 |
| - Stores the given [String] as a line in the file in Pascal format (i.e. also store the length of the string). Text will be encoded as UTF-8. This advances the file cursor by the number of bytes written depending on the UTF-8 encoded bytes, which may be different from [method String.length] which counts the number of UTF-32 codepoints. |
| 538 | + Stores the given [String] as a line in the file in Pascal format (i.e. also store the length of the string). Text will be encoded as UTF-8. This advances the file cursor by the number of bytes written depending on the UTF-8 encoded bytes, which may be different from [method String.length] which counts the number of UTF-32 codepoints. Returns [code]true[/code] if the operation is successful. |
539 | 539 | [b]Note:[/b] If an error occurs, the resulting value of the file position indicator is indeterminate.
|
540 | 540 | </description>
|
541 | 541 | </method>
|
|
544 | 544 | <param index="0" name="value" type="float" />
|
545 | 545 | <description>
|
546 | 546 | Stores a floating-point number in the file. This advances the file cursor by either 4 or 8 bytes, depending on the precision used by the current Godot build.
|
547 |
| - If using a Godot build compiled with the [code]precision=single[/code] option (the default), this method will save a 32-bit float. Otherwise, if compiled with the [code]precision=double[/code] option, this will save a 64-bit float. |
| 547 | + If using a Godot build compiled with the [code]precision=single[/code] option (the default), this method will save a 32-bit float. Otherwise, if compiled with the [code]precision=double[/code] option, this will save a 64-bit float. Returns [code]true[/code] if the operation is successful. |
548 | 548 | [b]Note:[/b] If an error occurs, the resulting value of the file position indicator is indeterminate.
|
549 | 549 | </description>
|
550 | 550 | </method>
|
551 | 551 | <method name="store_string">
|
552 | 552 | <return type="bool" />
|
553 | 553 | <param index="0" name="string" type="String" />
|
554 | 554 | <description>
|
555 |
| - Stores [param string] in the file without a newline character ([code]\n[/code]), encoding the text as UTF-8. This advances the file cursor by the length of the string in UTF-8 encoded bytes, which may be different from [method String.length] which counts the number of UTF-32 codepoints. |
| 555 | + Stores [param string] in the file without a newline character ([code]\n[/code]), encoding the text as UTF-8. This advances the file cursor by the length of the string in UTF-8 encoded bytes, which may be different from [method String.length] which counts the number of UTF-32 codepoints. Returns [code]true[/code] if the operation is successful. |
556 | 556 | [b]Note:[/b] This method is intended to be used to write text files. The string is stored as a UTF-8 encoded buffer without string length or terminating zero, which means that it can't be loaded back easily. If you want to store a retrievable string in a binary file, consider using [method store_pascal_string] instead. For retrieving strings from a text file, you can use [code]get_buffer(length).get_string_from_utf8()[/code] (if you know the length) or [method get_as_text].
|
557 | 557 | [b]Note:[/b] If an error occurs, the resulting value of the file position indicator is indeterminate.
|
558 | 558 | </description>
|
|
562 | 562 | <param index="0" name="value" type="Variant" />
|
563 | 563 | <param index="1" name="full_objects" type="bool" default="false" />
|
564 | 564 | <description>
|
565 |
| - Stores any Variant value in the file. If [param full_objects] is [code]true[/code], encoding objects is allowed (and can potentially include code). This advances the file cursor by the number of bytes written. |
| 565 | + Stores any Variant value in the file. If [param full_objects] is [code]true[/code], encoding objects is allowed (and can potentially include code). This advances the file cursor by the number of bytes written. Returns [code]true[/code] if the operation is successful. |
566 | 566 | Internally, this uses the same encoding mechanism as the [method @GlobalScope.var_to_bytes] method, as described in the [url=$DOCS_URL/tutorials/io/binary_serialization_api.html]Binary serialization API[/url] documentation.
|
567 | 567 | [b]Note:[/b] Not all properties are included. Only properties that are configured with the [constant PROPERTY_USAGE_STORAGE] flag set will be serialized. You can add a new usage flag to a property by overriding the [method Object._get_property_list] method in your class. You can also check how property usage is configured by calling [method Object._get_property_list]. See [enum PropertyUsageFlags] for the possible usage flags.
|
568 | 568 | [b]Note:[/b] If an error occurs, the resulting value of the file position indicator is indeterminate.
|
|
0 commit comments