You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
## Changelog:
* Fixed an issue with the `selected` keyword in the `<<cycle>>` and `<<listbox>>` macros' `<<option>>` tags.
* Fixed instances where using the `[img[]]` markup as an argument to macros would drop the `link-image` class.
* Fixed `Config.history.maxStates` to disallow unlimited states (value: `0`).
* Added the `init` special tag that, similar to `StoryInit`, allows pre-story-start initialization tasks. Intended for add-on/library use.
* Added a `data-init-passage` content attribute to `StoryInterface` that allows content to be updated only once at initialization.
* Added the `State.metadata.entries()` and `State.metadata.keys()` static methods.
* Added a `once` keyword to the `<<cycle>>` macro that ends the cycle upon reaching the final option.
* Added the `<Array>.countWith()` method.
* Added the `Save` Events API.
* Added support for template literals within TwineScript.
* Added various accessibility improvements.
* Updated the `<<done>>` macro to better serve when used to wait for DOM updates.
* `<<widget>>` macro updates:
* Added a `container` keyword that allows non-void/container widgets and an associated `_contents` special variable.
* Added a new special arguments variable, `_args`, and deprecated the old variable, `$args`.
* Updated the default value of `Config.history.maxStates` from `100` to `40`.
* Updated passage objects to maintain the order of passage tags as specified in the data chunk.
* Deprecated the `Config.saves.onLoad` and `Config.saves.onSave` settings in favor of the `Save` Events API.
* Updated bundled library: `jQuery` to v3.6.0.
* Updates to locale files:
* Updated the localization template. Translators are asked to updated the locale files as necessary.
* Added `nl.js` – Dutch.
* Various documentation updates.
* Various internal improvements.
* Build system updates.
Sets the maximum number of states (moments) to which the history is allowed to grow. Should the history exceed the limit, states will be dropped from the past (oldest first). A setting of `0` means that there is no limit to how large the history may grow, though doing so is not recommended.
80
+
Sets the maximum number of states (moments) to which the history is allowed to grow. Should the history exceed the limit, states will be dropped from the past (oldest first).
81
+
82
+
<prole="note"class="tip"><b>Tip:</b>
83
+
For game-oriented projects, as opposed to more story-oriented interactive fiction, a setting of <code>1</code> is <strong><em>strongly recommended</em></strong>.
84
+
</p>
81
85
82
86
#### History:
83
87
84
88
*`v2.0.0`: Introduced.
89
+
*`v2.36.0`: Reduced the default to `40`.
85
90
86
91
#### Examples:
87
92
88
93
```
89
-
// No history limit (you should never do this!)
90
-
Config.history.maxStates = 0;
91
-
92
-
// Limit the history to a single state
94
+
// Limit the history to a single state (recommended for games)
93
95
Config.history.maxStates = 1;
94
96
95
-
// Limit the history to 150 states
96
-
Config.history.maxStates = 150;
97
+
// Limit the history to 80 states
98
+
Config.history.maxStates = 80;
97
99
```
98
100
99
101
@@ -426,9 +428,16 @@ Config.saves.autoload = function () {
Determines whether the autosave is created/updated when passages are displayed.
434
+
435
+
Valid values are:
430
436
431
-
Determines whether the autosave is created/updated when passages are displayed. Valid values are boolean `true`, which causes the autosave to be updated with every passage, an array of strings, which causes the autosave to be updated for each passage with at least one matching tag, or a function, which causes the autosave to be updated for each passage where its return value is truthy.
437
+
* Boolean `true`, which causes the autosave to be updated with every passage.
438
+
* Boolean `false`, which causes the autosave to never update automatically—i.e., you must do it manually via the <ahref="#save-api-method-autosave-save"><code>Save.autosave.save()</code> static method</a>.
439
+
* An array of strings, which causes the autosave to be updated for each passage with at least one matching tag.
440
+
* A function, which causes the autosave to be updated for each passage where its return value is truthy.
432
441
433
442
<prole="note"class="warning"><b>Warning:</b>
434
443
When setting the value to boolean <code>true</code>, you will likely also need to use the <ahref="#config-api-property-saves-isallowed"><code>Config.saves.isAllowed</code> property</a> to disallow saving on the start passage. Or, if you use the start passage as real part of your story and allow the player to reenter it, rather than just as the initial landing/cover page, then you may wish to only disallow saving on the start passage the very first time it's displayed—i.e., at story startup.
@@ -445,6 +454,9 @@ When setting the value to boolean <code>true</code>, you will likely also need t
445
454
// Autosaves every passage
446
455
Config.saves.autosave = true;
447
456
457
+
// Allows manual autosaving
458
+
Config.saves.autosave = false;
459
+
448
460
// Autosaves on passages tagged with any of "bookmark" or "autosave"
449
461
Config.saves.autosave = ["bookmark", "autosave"];
450
462
@@ -490,93 +502,6 @@ Config.saves.isAllowed = function () {
Performs any required pre-processing before the save data is loaded—e.g., upgrading out-of-date save data. The callback is passed one parameter, the save object to be processed. If it encounters an unrecoverable problem during its processing, it may throw an exception containing an error message; the message will be displayed to the player and loading of the save will be terminated.
496
-
497
-
#### History:
498
-
499
-
*`v2.0.0`: Introduced.
500
-
501
-
#### Callback parameters:
502
-
503
-
***`save`:** (*object*) The save object to be pre-processed.
504
-
505
-
#### Save object:
506
-
507
-
<prole="note"><b>Note:</b>
508
-
See the <ahref="#save-api-save-objects">save objects</a> section of the <ahref="#save-api">Save API</a> for information on the format of a save.
Performs any required post-processing before the save data is saved. The callback is passed two parameters, the save object to be processed and save operation details object.
524
-
525
-
#### History:
526
-
527
-
*`v2.0.0`: Introduced.
528
-
*`v2.33.0`: Added save operation details object parameter to the callback function.
529
-
530
-
#### Callback parameters:
531
-
532
-
***`save`:** (*object*) The save object to be post-processed.
533
-
***`details`:** (*object*) The save operation details object.
534
-
535
-
#### Save object:
536
-
537
-
<prole="note"><b>Note:</b>
538
-
See the <ahref="#save-api-save-objects">save objects</a> section of the <ahref="#save-api">Save API</a> for information on the format of a save.
539
-
</p>
540
-
541
-
#### Save operation details object:
542
-
543
-
A save operation details object will have the following properties:
544
-
545
-
***`type`:** (*string*) A string representing how the save operation came about—i.e., what caused it. Possible values are: `'autosave'`, `'disk'`, `'serialize'`, `'slot'`.
546
-
547
-
#### Examples:
548
-
549
-
##### Using only the save object parameter
550
-
551
-
```
552
-
Config.saves.onSave = function (save) {
553
-
/* code to post-process the save object */
554
-
};
555
-
```
556
-
557
-
##### Using both the save object and operation details parameters
558
-
559
-
```
560
-
Config.saves.onSave = function (save, details) {
561
-
switch (details.type) {
562
-
case 'autosave':
563
-
/* code to post-process the save object from autosaves */
564
-
break;
565
-
case 'disk':
566
-
/* code to post-process the save object from disk saves */
567
-
break;
568
-
case 'serialize':
569
-
/* code to post-process the save object from serialize saves */
570
-
break;
571
-
default: /* slot */
572
-
/* code to post-process the save object from slot saves */
This setting has been deprecated and should no longer be used. See the <ahref="#save-api-method-onload-add"><code>Save.onLoad.add()</code></a> method for its replacement.
570
+
</p>
571
+
572
+
#### History:
573
+
574
+
*`v2.0.0`: Introduced.
575
+
*`v2.36.0`: Deprecated in favor of the [`Save` Events API](#save-api-events).
This setting has been deprecated and should no longer be used. See the <ahref="#save-api-method-onsave-add"><code>Save.onSave.add()</code></a> method for its replacement.
583
+
</p>
584
+
585
+
#### History:
586
+
587
+
*`v2.0.0`: Introduced.
588
+
*`v2.33.0`: Added save operation details object parameter to the callback function.
589
+
*`v2.36.0`: Deprecated in favor of the [`Save` Events API](#save-api-events).
0 commit comments