(link-undo: String) → Command

Takes a string of link text, and produces a link that, when clicked, undoes the current turn and sends the player back to the previously visited passage. The link appears identical to a typical passage link. This command should not be attached to a hook.

Example usage:

(link-undo:"Retreat") behaves the same as (link:"Retreat")[[[harlowe:undo|(undo:)]]].

Rationale:

The ability to undo the player's last turn, as an alternative to (go-to:), is explained in the documentation of the (undo:) macro. This macro provides a shorthand for placing (undo:) inside a (link:) attached hook.

You may, as part of customising your story, be using (replace:) to change the ?sidebar, and remove its default “undo” link. If so, you can selectively provide undo links at certain parts of your story instead, by using this macro.

Details:

As with (undo:), if this command is used on the play session's first turn, an error will be produced (as there is yet nothing to undo at that time.) You can check which turn it is by examining the length of the (history:)Array.

See also:

(undo:), (link-goto:)