Basic Arcweave tutorial | Part 12: Text with logic
Add logic to an element's text content.
Video tutorial
Watch this tutorial as a video:
⚠️ This video does not reflect the latest updates to Arcweave's UI.
✅ You can play the finished version of the Tutorial Project here and explore its diagrams and structure here.
Text with logic
In the previous part of this tutorial, you learned how to use branches to control narrative flow with if, elseif, and else statements.
In this part, you'll learn how to write Arcscript logic inside element content to dynamically change the text a player sees.
This is a classic technique in interactive fiction. A location description can differ depending on whether it's day or night, or whether the player is visiting for the first time or not. This helps the game stay fresh and avoid annoying levels of repetition.
In our tutorial game, we'll use variables to shape NPC dialogue based on the player's earlier choices.
New variable
We want to track whether the player has taken a shower before their appointment. To do this, we need a new variable.
- Open the Global variable dialog.
- Create a new variable named
shower_taken. - Set its type to Boolean.
- Set its initial value to false.
Variable assignment
Now we need to assign true to shower_taken when the player chooses to shower.
- Navigate to the Beginning board and locate the element where the player takes a shower (for example, Take a shower from Part 2).
- Open the element and add a code segment at its end:
shower_taken = true - Connect the shower element to the element where the player arrives at the apartment (Horace opens the door in Part 9), so the player can proceed to the appointment after showering.
Also make sure that the path that skips the shower leads directly to the same apartment-arrival element. This way, both paths are available to the player: with shower or without.
Conditional element text
Now let's make the dialogue at the apartment door (the Horace opens the door element) react to whether the player has showered.

✅ You already know how to add Arcscript segments by clicking Arcscript (the <> icon in the formatting menu). You can do the same using the keyboard: press Ctrl+Shift+C or Cmd+Shift+C.
So, the content of the Horace opens the door element can be:
Horace Linetti opens the door and lets you in.
if shower_taken
"You're late!" he says.
else
"Good Lord! You smell as if you've spent the night on an office floor," he says, fanning the air with his hand.
endif
You enter the apartment. As you marvel at the design of the living room, he disappears towards the bedrooms. "Let me know if you find my grandmother's ring," he hollers.⚠️ Every
ifstatement must be closed with a respectiveendifor Arcweave will display an error symbol at the element's bottom-right corner.
✅ Notice how Arcweave takes care of conditional text's indentation. Any rich text that is enclosed by
ifandendifis automatically indented.
Test
Let's test what we've built. Set the first element of the Beginning board as the starting element (Play Mode > Set Play Mode start) and enter Play Mode.
Try both paths:
- Skip the shower: Go straight to the appointment and knock the door. Horace lets you in, commenting on your odor.
- Shower first: Take the shower, go to the appointment, and knock the door. Horace says "You're late."
Paragraph breaks
You may notice that text on either side of a code segment renders on the same line, forming one large paragraph. This happens because code segments do not automatically insert a paragraph break.
To control where breaks appear, manually press Enter before or after the if expression. Until you are more experienced, it will take some testing to see what works best for each case.
Nested if statements
Arcscript supports nested if statements: if/endif blocks placed inside other if/endif blocks. This allows you to combine multiple conditions.
✅ We call them
if/endifblocks sinceifandendifare the absolutely essential statements of a conditional block.elseif/elsecan still be part of these blocks.
In this example, we'll add nested conditional text to the Bathroom element:
Marble and gold. You never really understood some people's extravagance.
The bathtub is huge.
if shower_taken
It must be such a different experience from showering in one's office.
if not has_key
But you need to focus, see if you can find anything, here.
endif
else
Mmm... You wonder if it's too much asking the Linettis if you could take a quick shower, here. You'd do them a favour, after all.
endif⚠️ Notice how the inner
ifblock closes with itsendifstatement, before the outerelsecomes. If the inner block is left open, theelsewill be treated as belonging to the innerif, not the outer one.
Logical operators
You can combine multiple conditions in a single if statement using the logical operators and and or.
and
The following code shows text only if the player has not showered AND is carrying the ring (i.e., ring_state equals 1):
if not shower_taken and ring_state == 1
You may stink, but look at that ring!
endifBoth conditions must be true for the block to render.
ℹ️ The
andkeyword can also be written as&&.
or
The following code shows text only if EITHER the player has not showered OR is carrying the ring:
if not shower_taken or ring_state == 1
...
endifThe block renders if either condition is true.
ℹ️ The
orkeyword can also be written as||.
What's next
In this tutorial you learned how to assign variable values and create conditional, dynamic text.
In the next tutorial, we'll explore two built-in functions that make your text and outcomes even more dynamic.