Story API. Determines whether saving to disk is enabled on mobile devicesi.e., smartphones, tablets, etc. Determines whether certain elements within the UI bar are updated when passages are displayed. If you need to check for multiple passages, the hasVisited() story function will likely be more convenient to use. The data-init-passage attribute causes the element to be updated once at initialization, while the data-passage attribute causes the element to be updated upon each passage navigation. Renders the selected passage into the target element, replacing any existing content, and returns the element. Now, load the saved story from before the changes were made, and you'll see $y is undefined, since it doesn't exist at all in the loaded state. Engine API. The entire Options systemMenuOptions special passage, options special variable, and associated macroshas been scrapped for numerous reasonsit was always a hack, required copious amounts of boilerplate code to be useful, etc. Returns whether a playlist with the given list ID exists. Note: Prior to SugarCube v2.10.0, the strings localization object was named strings. Creates a checkbox, used to modify the value of the variable with the given name. Most of the methods listed below are SugarCube extensions, with the rest being either JavaScript natives or bundled library methods that are listed here for their utilitythough, this is not an exhaustive list. Deprecated: SimpleAudio API, AudioRunner API, and AudioList API. Renders and displays the active (present) moment's associated passage without adding a new moment to the history. Etc. Returns a new array consisting of all of the tags of the given passages. If you simply need a passage link that modifies variables, both the link markup and image markup offer setter variants. See LoadScreen API for more information. See the Config API docs for more information. The story metadata store is not, and should not be used as, a replacement for saves. SugarCube is a free (gratis and libre) story format for Twine/Twee. When a saved story is loaded, the state loaded from the save replaces the current state. Passage API. For example: Warning: Additionally, macros in SugarCube do not return values, so macros cannot be used as arguments to other macros. Returns whether the history navigation was successful (should only fail if the offset from the active (present) moment is not within the bounds of the full history). Determines whether the link-visited class is added to internal passage links that go to previously visited passagesi.e., the passage already exists within the story history. Functionally identical to <>. Essentially, a combination of <> and <>. Warning: See Also: In SugarCube, both variables would still point to the same underlying objectat least initially (see below): SugarCube does eventually clone its non-primitive data types as well, but does at the start of passage navigation, rather than each time they're modified. classes) guide for more information. Returns the title of the passage associated with the active (present) moment. Adds the named property to the settings object and a toggle control for it to the Settings dialog. Starts playback of the playlist and fades the currently playing track between the specified starting and destination volume levels over the specified number of seconds. Attaches single-use event handlers to the selected tracks. Block widgets may access the contents they enclose via the _contents special variable. To enable test mode, use the test option (-t, --test). Returns whether the history navigation was successful (should only fail if already at the end of the full history). Appends one or more members to the end of the base array and returns its new length. Due to how SugarCube stores the state history a few constructs are not supported within story variables. While not specifically about SugarCube, the About Expressions section of the Twine1 reference documentation may also be helpful. Note: Local event triggered on the typing wrapper when the typing of a section stops. See the Save API docs for more information. If its return value is truthy, the save is allowed to continue unperturbed. An array of strings, which causes the autosave to be updated for each passage with at least one matching tag. Deprecated: Its return value should be the post-processed text. Iterates through all enumerable entries of the given collection. If multiple passage titles are given, returns the logical-AND aggregate of the seti.e., true if all were found, false if any were not found. Passage names have passage- prepended to their converted forms and are converted both into IDs and classes depending on how the passage is usedan ID for the active passage, classes for included (via <>) passages. A list definition object should have some of the following properties: Adds the named property to the settings object and a range control for it to the Settings dialog. This method has been deprecated and should no longer be used. Instance methods of classes are not affected by either issue, as they're never actually stored within story variables, being referenced from their classes' prototypes instead. Performs any required processing before the save data is loadede.g., upgrading out-of-date save data. Returns a reference to the current jQuery object for chaining. Returns a reference to the current AudioRunner instance for chaining. Be very careful with these if your audio sources are on the network, as you are forcing players to begin downloading them. Determines whether the UI bar (sidebar) starts in the stowed (shut) state initially. Returns whether the dialog is currently open. SimpleAudio API. Returns whether any valid sources were registered. See the <> macro for its replacement. The most common way to resolve this arbitrarily long return issue is to use a bit of JavaScript to record the last non-menu passage the player visited into a story variable and then to create a link with that. This macro has been deprecated and should no longer be used. See Dialog API for more information. Note: Begins playback of the selected tracks or, failing that, sets the tracks to begin playback as soon as the player has interacted with the document. Note: Determines whether passage titles are combined with the story title, within the browser's/tab's titlebar, when passages are displayed. This macro is an alias for <>. Any passage may be chosen as the starting passage by selecting it via the Start Story Here passage context-menu itemn.b. This function is finicky, however. Gets or sets the track's repeating playback state (default: false). Determines whether the autosave is created/updated when passages are displayed. Returns the description of the passage, created from either an excerpt of the passage or the Config.passages.descriptions setting. Groups are useful for applying actions to multiple tracks simultaneously and/or excluding the included tracks from a larger set when applying actions. Note: Warning: Returns whether the autosave is available and ready. State.top is not a synonym for State.active. Note: See Fullscreen API for more information. A toggle definition object should have some of the following properties: Adds the named property to the settings object and a list control for it to the Settings dialog. Returns the number of times that the given member was found within the array, starting the search at position. The Share dialog only displays linksspecifically, anything that creates an anchor element (). SugarCube preserves the state of the story as it's being played in a number of ways to both prevent the loss of progress and allow players to save stories. Does not modify the original. Generally, only really useful for formatting blocks of macros for ease of use/readability, while ensuring that no output is generated, from spacing or whatnot. Silently executes its contents as pure JavaScript codei.e., it performs no story or temporary variable substitution or TwineScript operator processing. Making custom non-generic object types fully compatible requires that two methods be added to their prototype, .clone() and .toJSON(), to support cloningi.e., deep copyinginstances of the type. May be called with either the link text and passage name as separate arguments, a link markup, or an image markup. Returns whether playback of the track has ended. Note: In the above, the second (set:) macro is never run, and the $count variable remains at 0. Returns the total number (count) of played moments within the extended past history (expired + past). Object that authors/developers may use to set up various bits of static data. The list options are populated via <