0 votes
by (120 points)

Just learning Twine 2.0 and building a simple branching story flow to practice. Is it possible to change the color a variable whenever its text is displayed using <<set>>? Would make life much simpler than running down every possible combination and adding text-change HTML. 

Example: if the player chooses one of three colors for their Road variable in Passage 1, can I set both the value and the color for their Road choice in Passage 2 somehow?

 

(set: $life to "...")
(set: $road to "Yellow")

You're walking down the $road road and pass by a tree.

What does it look like?

[[Alive]]
(put: "Alive" into $tree)
[[Growing]]
(put: "Growing" into $tree)
[[Spooky]]
(put: "Spooky" into $tree)
[[Stunted]]
(put: "Stunted" into $tree)
[[Withered]]
(put: "Withered" into $tree)

 

1 Answer

0 votes
by (156k points)

You need to state which story format (name and full version number) you are using, as answers can be different for each one.
Your question title includes the <<set>> macro from SugarCube but your example contains Harlowe syntax macros, based on your example I am going to assume you are using Harlowe v1.2.4 as your story format.

Harlowe has a (text-colour:) macro which can be used to either directly colour text or it's return value can be assigned to a story variable while can be used to colour text instead.

(set: $colour to (text-colour: "yellow"))

$colour[This text should be yellow]

(set: $colour to (text-colour: "green"))

$colour[This text should be green]

As explained in the macro's documentation you need to pass a valid colour value to the macro.

Welcome to Twine Q&A, where you can ask questions and receive answers from other members of the community.

You can also find hints and information on Twine on the official wiki and the old forums archive.

See a spam question? Flag it instead of downvoting. A question flagged enough times will automatically be hidden while moderators review it.
...