Trying to update variables within a passage

From what I’ve read this seems like it needs a workaround or I need a better understanding of how the History system works. Trying to update $theBool so I can turn off a passage appearing more than once.

::Main Passage
<<set $theBool = false>> 
@@#chat;
@@

@@#links;
<<link "Passage 1">><<include "Passage1">><</link>>
<<link "Passage 2">><<include "Passage2">><</link>>
<<link "Passage 3">><<include "Passage3">><</link>>
@@
::Passage1
<<append "#chat">>
Lots of text

<</append>>
<<replace "#links" t8n>>
@@#links;
<<if $theBool == false>>
<<link "Passage2">><<set $theBool = true>><<include "Passage2">><</link>>
<</if>>
<<link "Passage3">><<include "Passage3">>
<</link>>
@@
<</replace>>
::Passage2
<<append "#chat">>
Even more text, but this time I only want to have the option to play it once, specifically by changing a variable if possible.

<</append>>
<<replace "#links" t8n>>
@@#links;
<<link "Passage1">><<include "Passage1">>
<</link>>
<<link "Passage3">><<include "Passage3">>
<</link>>
@@
<</replace>>
::Passage3
<<append "#chat">>
Other boring text

<</append>>
<<replace "#links" t8n>>
@@#links;
<<link "Passage1">><<include "Passage1">>
<</link>>
<<if $theBool == false>>
<<link "Passage2">><<set $theBool = true>><<include "Passage2">><</link>>
<</if>>
@@
<</replace>>

Just trying to find some way to gate off parts of the conversation as the conversation is explored.

Also sorry if this isn’t how the post is supposed to be formatted, first post here.

1 Like

Hey, I put your example code into Twine. I had a few issues since I think your @@#links; stuff is supposed to be on the outside of the replace block (since the replace block is trying to access it) and also I had to put a <<timed>> block around the replace (since replace operates on elements already on the page, not elements that are still rendering). Not sure if those were just issues introduced when you simplified your code to post or not.

But once I fixed those two things, your logic worked. After visiting Passage2, it never appeared in the list again. Is there something else not working as you expected?

1 Like

You only need to define the area with a links ID once, not each time you call a <<replace>> macro that targets that identified area.

The following variation of your example may achieve the effect you are looking for, although I’m not 100% sure what effect you are trying to achieve.

:: Main Passage
<<set $theBool to false>> 
@@#chat;
@@

@@#links;
<<nobr>>
	<<link "Passage1">><<include "Passage1">><</link>>
	<<if not $theBool>>
		<br><<link "Passage2">><<set $theBool to true>><<include "Passage2">><</link>>
	<</if>>
	<br><<link "Passage3">><<include "Passage3">><</link>>
<</nobr>>
@@

:: Passage1
<<append "#chat">>
Lots of text

<</append>>
<<replace "#links" t8n>>
	\<<nobr>>
		<<if not $theBool>>
			<<link "Passage2">><<set $theBool to true>><<include "Passage2">><</link>><br>
		<</if>>
		<<link "Passage3">><<include "Passage3">><</link>>
	<</nobr>>
<</replace>>

:: Passage2
<<append "#chat">>
Even more text, but this time I only want to have the option to play it once, specifically by changing a variable if possible.

<</append>>
<<replace "#links" t8n>>
	\<<link "Passage1">><<include "Passage1">><</link>>
	<<link "Passage3">><<include "Passage3">><</link>>
<</replace>>

:: Passage3
<<append "#chat">>
Other boring text

<</append>>
<<replace "#links" t8n>>
	\<<nobr>>
	<<link "Passage1">><<include "Passage1">><</link>>
	<<if not $theBool>>
		<br><<link "Passage2">><<set $theBool to true>><<include "Passage2">><</link>>
	<</if>>
	<</nobr>>
<</replace>
1 Like

Sorry about typing out that code wrong. I got the simplified code to work as well which is confusing for me because the actual code is basically just a longer version with more passages. I’m adding the <> blocks into the code now.

Someone else pointed out that @@#links; doesn’t even need to be in there more than once so I’m taking the extra out as well.

You only need to define the area with a links ID once, not each time you call a <<replace>> macro that targets that identified area.

The following variation of your example may achieve the effect you are looking for, although I’m not 100% sure what effect you are trying to achieve.

Thanks, I’m trying that out right now. I’ve cleaned up all the @@#links; as well.

I rewrote a couple of passages and it works now, ultimately not really sure what fixed it. Thanks for the help though!

1 Like