The <<revision>>
macro is a more powerful variation of the <<replace>>
macro. It lets you alter a span of passage text by clicking a link from anywhere in the passage.
Install my <<Replace>> Macro Set to use these macros.
Basic usage
First, use the <<revision>>
macro to define two different versions of some text:
You see here <<revision tome>>a closed book.<<becomes>>an open book.<<endrevision>>
Each section of text separated by <<becomes>>
is a different "version" of the text. The name "tome" in the macro is an identifier. You can use any single word you want as an identifier.
Then, you can create a link using the <<revise>>
like so:
<<revise tome "Open the book.">>
This creates a link reading "Open the book" that changes any "tome" revision in the passage into the next version - in this case, changing "a closed book" into "an open book".
(Notice that the word "revise" is the verb form of "revision", reflecting the fact that the hyperlink serves as a verb for the player to perform.)
Running code in revisions
Just like with <<replace>>
, any macros inside a revision are run as soon as they are made to appear:
<<revision button>>You see a button.<<becomes>>The button is pushed.<<set $button=true>><<endrevision>> <<revise button "Push it.">>
Multiple versions
You can have many versions of a span of text:
You see here <<revision books>>a closed book.<<becomes>>a chewed book.<<becomes>>paper scraps.<<endrevision>> <<revise books "Chew book">>
Back and forth
The <<revert>>
macro functions to reverse the effects of the <<revise>>
macro.
<<revision box>>Here is a closed box.<<becomes>>Here is an open box.<<endrevision>> <<revise box "Open the box.">> <<revert box "Close the box.">>
The <<revert>>
macro's link won't be displayed if it's at the first revision, just as the <<revise>>
macro won't be visible if it's at the last revision.
Cycling link text options (New)
The <<revise>>
and <<revert>>
macros have a number of additional options similar to the <<cyclinglink>>
macro. You can supply additional link text strings after the first, and it will change to the next string after you click it.
<<revise wall "Smash wall" "Smash it again" "Keep smashing">>
If the second parameter begins with the "$" sigil, then it will interpret it as a variable to be altered by clicking the link. When the player clicks the link, the variable will be changed to match the text of the link.
<<revise heat $warmth "Set it to warm" "Set it to hot" "Set it to boiling">>
If the last parameter is the word "end", then it will disable the link at the parameter before last, leaving just the text. If the last parameter is the word "out", then it will vanish altogether once it's reached the final string.
<<revise roast "Devour roast" "Munch some more" "You're too full now" end>>
<<revise amphora "Drink wine" out>>
<<hoverrevise>>
Click here to read about <<hoverrevise>>
.
<<becomes>> vs. <<gains>>
Just as the <<replace>>
macro has a variation, <<insert>>
, so too does <<becomes>>
.
The vase contains:<<revision vase>>Two roses<<gains>>, an orchid<<gains>>, a pencil<<gains>>, a straw<<endrevision>>. <<revise vase "Put something in the vase">>.
You can mix and match <<gains>>
and <<becomes>>
at will:
<<revision count>>One<<becomes>>Two<<gains>>and a half<<becomes>>Three!<<endrevision>>
<<cycle>>
Normally, when a <<revision>>
macro reaches the end of its revisions, its links disappear. If you change "revision" to "cycle", then you can keep clicking the link to return to the first revision.
You see here <<cycle pet>>a dog<<becomes>>a cat<<endcycle>>. <<revise pet "Change pet">>
<<insertion>> and <<removal>>
Two other variations exist, which are roughly analogous to <<timedinsert>>
and <<timedremove>>
.
You look at the plate. <<insertion grain>>1 grain.<<becomes>>2 grains.<<becomes>>3 grains.<<endinsertion>>
For <<insertion>>
, the first version "1 grain" is initially invisible. Clicking a <<revise>>
link will make it visible. Then, it functions as normal.
You look at the plate. <<removal seed>>3 seeds.<<becomes>>2 seeds.<<becomes>>1 seed.<<endremoval>>
For <<removal>>
, the <<revise>>
link will remain when you get to "1 seed". Clicking it a final time will remove the text altogether.
Example program
http://www.glorioustrainwrecks.com/files/TwineMacro-RevisionTest.html
Technical details
<<revision>>
macro is a <span>
classed with "revision-span" as well as the kind of version they are ("becomes", "gains"). When they appear, they are given the class "revision-span-in" and their display is set to "inline". When they disappear, they gain the class "revision-span-out" and, after 1 second, their display is set to "none". All of these are inside a container <span>
classed with the name of the macro ("insertion", "removal", "cycle", "revision") and the name of the identifier ("book" or whatever the author set it to be).Version history:
<<revision>>
macros were being called twice on passage load.<<revision>>
macros were still taking effect while they were animated being removed by other macros.<<revision>>
macros with the same ID weren't all being revised at the same time.<<revise>>
.<<hoverrevise>>
and support for <<randomise>>
.Attachment | Size |
---|---|
TwineMacro-RevisionTest.html | 68.47 KB |
TwineMacros-Revision-1.2.0.txt | 9.87 KB |
Comments
revise links appear a little abruptly?
Is there a way for them to appear in line with the rest of the text?