+1 vote
by (530 points)
retagged by
Harlowe 2.1.0

Hey everyone, I have an $alcohol variable that tracks the player character's level of intoxication. If/after that variable exceeds a certain number, I'd like to apply text-style: "blur" to random words in every passage. How would I go about doing this?

Thank you!

2 Answers

+1 vote
by (6.2k points)
selected by
 
Best answer
(either: 'Some','(text-style: "blur")[Some]') (either: 'of','(text-style: "blur")[of]') (either: 'the','(text-style: "blur")[the]') (either: 'words','(text-style: "blur")[words]') (either: 'in','(text-style: "blur")[in]') (either: 'this','(text-style: "blur")[this]') (either: 'sentence','(text-style: "blur")[sentence]')...

It's very messy, but perhaps using the (either:) you could come up with a cleaner solution.

+1 vote
by (159k points)

Please use the Question Tags to state the name and full version number of the story format you are using, placing that information within the Question Titile just makes it longer than it needs to be.

The solution to your issues consists of two parts:

1. Marking the text you want to conditionally apply the effect to.

You can use named hooks with with a predetermined name (like blurable) to do this.

2. Conditionally appling the enchantment to the marked text.

You can use the (if:) macro to check the current value of the $alcohol variable each time the Passage is displayed, then use a combination of the (enchant:) macro and the (text-style:) macro to enxhant the known named hook.

Some of the [words]<blurable| in this [sentance]<blurable| will become [blured]<blurable| when \
the value of [alcohol]<blurable| variable becomes large enough.

(if: $alcohol > 5)[
    (enchant: ?blurable, (text-style: "blur"))
]

 

by (530 points)
edited by
Thanks, but I was hoping to apply the effect to random words rather than picking and choosing which words will be blurred and which won't. That would be ideal so I don't have to manually insert multiple hooks per sentence across 20+ passages. Is this possible?

Barring that, is it possible to apply the hooks based on a sequence (every 5th word is blurred)?
...