I've worked hard to combine my <<replace>>
, <<timedreplace>>
, <<revision>>
, <<hoverreplace>>
and <<once>>
macros into a single codebase, and included some new variations thereof. Here's my combined "Replace Macro Set":
http://l.j-factor.com/twine/macros/ReplaceMacros.js
CSS
The first good news is that you only need this much default CSS for all these macros:
.revision-span-in { opacity: 0; } .revision-span:not(.revision-span-out) { transition: 1s; -webkit-transition: 1s; } .revision-span-out { position:absolute; opacity: 0; }
List of macros
This set includes the following "revision macros":
* <<insert>>
, <<replace>>
, <<continue>>
— triggered by clicking their contents.
* <<timedreplace>>
, <<timedinsert>>
, <<timedremove>>
, <<timedcontinue>>
, <<timedcycle>>
— triggered by time.
* <<hoverreplace>>
, <<hoverremove>>
— triggered by the mouse touching their contents, only temporarily.
* <<mousereplace>>
, <<mouseremove>>
, <<mousecontinue>>
, <<mousecycle>>
— triggered by the mouse touching their contents, permanently.
* <<once>>
, <<later>>
— triggered by visiting the passage a certain number of times in the game session.
* <<insertion>>
, <<revision>>
, <<removal>>
, <<cycle>>
— triggered by a separate "triggering macro".
It also includes these "triggering macros":
* <<revise>>
, <<revert>>
, <<randomise>>
— hyperlinks.
* <<mouserevise>>
, <<hoverrevise>>
— sections that the mouse can touch.
Changed syntax
* <<replacewith>>
, used to separate sections in <<timedreplace>>
, has been replaced with <<becomes>>
.
* You can now have multiple sections in most of the revision macros, by separating them with <<becomes>>
or <<gains>>
macros:
These function just like they do within <<revision>>
macros - <<becomes>>
replaces the previous section with the next section, and <<gains>>
merely appends the next section.
* To reconcile differences between <<replace>>
and <<timedreplace>>
's syntax, some macros (currently just the <<replace>>
, <<mousereplace>>
and <<hoverreplace>>
varieties) have multiple syntax for specifying sections - the "normal" syntax, where each section is separated by <<becomes>>/<<gains>>
, and a "shorthand" syntax, where the first several sections are strings within the opening tag:
The final section must be between the opening tag and the <<endreplace>>
macro tag, though.
For most of these, the shorthand strings behave as if the <<becomes>>
macro separates them. The exception to this is the "insert" named macros, wherein the strings will behave as if the <<gains>>
macro separates them.
New macros
* <<later>>
is the antonym of <<once>>
- it displays its contained text on the second and subsequent visits.
* <<mousecycle>>
creates a section of text that cycles between different versions whenever the mouse touches it. It's similar to <<cyclinglink>>
in some respects, though you can't yet easily bind a variable to change when it changes.
* <<timedcycle>>
constantly rotates through its sections without stopping. It is similar to <<timedloop>>
and may well replace it in future.
Examples
In any of these examples, <<becomes>>
can be substituted with <<gains>>
.
Version history
* 15-6-13: Initial script.
Feel free to report any bugs to @webbedspace.