0 votes
by (8.7k points)

I'd like to use <<linkreplace>> as a kind of conversation engine.  If the player clicks certain options, I'd like the game to <<set>> a variable.  For example:

"But Alderaan is a peaceful planet!" you protest.

"You would prefer another target, a military target?" demands Tarkin.  "Then name the system!"

<<linkreplace "Tell the truth".>>"Yavin 4," you murmur.<</linkreplace>>

In this instance, I'd like to <<set $rebelAllianceStatus to "doomed">> once the player clicks "Tell the truth".  But inserting that into the <<linkreplace>> macro doesn't seem to work.  Is there an alternative?

1 Answer

+1 vote
by (63.7k points)
selected by
 
Best answer

Placing the <<set>> within the <<linkreplace>> will work just fine.  For example:

<<linkreplace "Tell the truth".>><<set $rebelAllianceStatus to "doomed">>"Yavin 4," you murmur.<</linkreplace>>

 

by (61.5k points)

But inserting that into the <<linkreplace>> macro doesn't seem to work.

As a side note,  'doesn't work' isn't a really great description of a problem.  As @TheMadExile points out, it does work, which means the question probably becomes what is it not doing that you want it to do?  It's best to be specific.  Are you getting an error?  Is the variable not updating, and if so, how are you testing it to see if it's updating?  What exact code did you try?  Etc.

by (8.7k points)

Thanks!  You're right, it works perfectly.

I had foolishly placed <<print $rebellionStatus>> on the same page as the <<linkreplace>>.  So the variable had updated, but the print macro hadn't reloaded.  I misdiagnosed the problem.

When you informed me that it did work, I figured out the real problem was user error.  Thanks, Exile.  :-)

by (8.7k points)
That is good advice, Chapel.  I will do so in future.
by (790 points)
Okay, I actually did not know that you could do that within a linkreplace. =O.o=

I feel a bit slow now.
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.
...