0 votes
by (8.9k 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 (68.6k 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 (63.1k 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.9k 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.9k points)
That is good advice, Chapel.  I will do so in future.
by (820 points)
Okay, I actually did not know that you could do that within a linkreplace. =O.o=

I feel a bit slow now.
...