Fewer nodes for the same graph
What this page is for
Section titled “What this page is for”A scheme grows by small steps: one Set Variable after another, a row of Compare Variable nodes that ask about the same variable, a node behind every dialogue choice. This lesson shows the ways the Studio gives you to say the same thing with fewer nodes. None of them changes what the scheme does.
When you come here
Section titled “When you come here”- You have two or more Set Variable nodes in a row.
- A chain of Compare Variable nodes asks about one variable again and again.
- You need to ask about something no named condition node covers.
- A dialogue choice only leads to a Set Variable node.
- Two branches end with the same nodes, and you have a copy on each.
What you see
Section titled “What you see”A scheme drawn the long way has a card, or a folded line, for every step. The new tools replace a group of steps with one.
| Instead of | Use | Where |
|---|---|---|
| Set Variable nodes one after another | One Set Variable with more changes | The canvas command Merge into One Set Variable |
| A chain of Compare Variable nodes on one variable | Branch By Value | The Variables group of the node menu |
| A condition that has no node of its own, or a list of mixed conditions | Check | The Conditions group of the node menu |
| Add Policy and Remove Policy | Change Policy, with Add or Remove | The Clans & Roles group of the node menu |
| A Set Variable node behind a dialogue choice | The change Change any variable on the choice | When picked in the choice’s settings |
| The same tail copied onto several branches | One tail that every branch links to | Links on the canvas |
The named condition nodes, Add Policy and Remove Policy, and Compare Variable stay in the menu and work as before. A scheme you made earlier is not changed.
Do it, step by step
Section titled “Do it, step by step”Merge a run of Set Variable nodes
Section titled “Merge a run of Set Variable nodes”A run is a Set Variable node and the Set Variable nodes that follow it one after the other. Right-click a Set Variable card, or a folded Set Variable line, and choose Merge into One Set Variable. The command works in schemes only. It is grey when nothing you selected starts a run, or when the graph cannot be edited.
The command does this:
- It moves the changes of the later nodes into the first node, in order. The first node then has Change 1, Change 2 and so on, as when you add changes by hand with + Add another change.
- It gives the links of the last node to the first.
- It removes the later nodes.
The changes are made from top to bottom, and each sees the ones before it. If one cannot be made, the flow stops there and the earlier ones stay made. A chain of separate nodes does the same.
A later node joins the run only when:
- it is the only node the one before it links to, and that output has no other link;
- nothing else links to it, and no setting of another node names it (a jump or a Stop Wait, for example);
- it has no comment, because the comment would be lost;
- it has one output;
- it is in the same node group as the node before it.
The run stops at the first node that does not fit. Select several Set Variable nodes, and every run that starts at one of them is merged. A selected node inside another selected node’s run is merged by that one.
The whole command is one undo step, named Merge Into One Set Variable. Choose Undo in Unity’s Edit menu, and every node comes back.
A merged node is a card again when the last node of the run was a card. It stays a line only when the last node was a line too. See Folding: Then also.
The Studio also tells you when a merge is possible. A Set Variable whose only way on leads straight to another Set Variable, which nothing else links to, shows an information line in Reads as: The next node is also a Set Variable. Right-click and choose “Merge into One Set Variable” to make them one node. It adds no badge and is not counted. The line can show while the command is grey, for example when the second node has a comment.
Ask about one variable with Branch By Value
Section titled “Ask about one variable with Branch By Value”Use Branch By Value when a chain of Compare Variable nodes asks “is it this?”, “is it that?” about the same variable. It looks at one variable and takes the output of the first case that has the variable’s value. When no case does, it takes Otherwise.
- Add a Branch By Value node. Search for it, or find it in the Variables group of the menu. See Add and connect nodes.
- Pick the variable. It can be a text, a whole number, a yes/no value or a named choice (an Enum). Other kinds are not offered.
- Add a case for each value. The add link under the list has the hover text Add a case below the selected one. Each case has a Value and an optional Name. Name is shown on the case’s output. The hover text is The name shown on this case’s output. Empty: the value itself.
- Link each output. Otherwise is the first output. Every case has one output after it.
The cases are looked at from top to bottom, and the first one that fits runs. A text has to match exactly: upper and lower case count.
If you change the variable, the values of the cases follow the new kind in the same undo step. The undo steps are Add Case, Remove Case and Move Case.
An output keeps its links when you add, remove or move other cases. Each case has its own hidden key, so a link belongs to the case, not to its place in the list.
An output is named by the case’s Name, else by the value. A case for False or for 0 with no Name has an output called Case and its number. Give it a Name if you want to read it at a glance.
The card shows Branches by and the variable, then up to four lines of the form value, an arrow and the output’s name. More cases show as + N more.
Keep Compare Variable for a single yes/no question and for a range such as >=. Branch By Value tests for equal values only.
Check anything with the Check node
Section titled “Check anything with the Check node”Check holds a list of conditions of any kind and continues through True or False. Use it when a kind of condition has no node of its own. Memory, Budget, Joined by Marriage, Age Group and Has Modifier are kinds that exist only as rows of a condition list. Use it too when you want a list that mixes kinds.
- Add a Check node. It is in the Conditions group of the menu.
- In the Conditions section, click + Add condition and pick a kind. The list starts empty. A node with no condition shows the error Add at least one condition.
- Add more. With two or more, you choose whether all or any of them must be met, or click + Add an ‘or’ group to start another way to pass. Each condition has a not switch that turns it around. With ‘or’ groups, a thin OR row stands between two groups. The rows of Try it start with IF, AND or OR.
- Read the Try it section under the list. It says whether the conditions hold for a Conspirator and a Target you pick, and why not when they do not.
The node is True when the conditions are met. The rows work as in every condition list. How to write one is in Who? and condition lists.
The named nodes (Has Trait, Check Culture and the others) stay in the menu. They open with their fields laid out, which can be quicker for a single question. Check has no first condition that belongs to the node: every row can be moved or removed.
Add or remove a policy in one node
Section titled “Add or remove a policy in one node”Change Policy is Add Policy and Remove Policy in one node. Its Change setting is Add or Remove. The rest is as in the two older nodes: Belongs To (a clan, a family or a culture’s tradition), the clan, family or culture, and the Policy. It can be a line under an output, like the other two.
Whose Culture shows only while Belongs To is a culture and no culture is chosen. Pick a culture, and the row goes away. Add Policy, Remove Policy, Has Policy and May Change Law work the same way. In them the setting used to be named Culture Of.
Change any variable on a choice
Section titled “Change any variable on a choice”A dialogue choice can make changes when it is picked. In the choice’s settings the list is When picked, and its link reads + Add a change. The hover text says: Adds a change that is made when this choice is picked: any variable (also one of this scheme), a trait, a memory, a tie, an ambition, an attitude. Pick “Change any variable” for scheme and clan variables.
Pick Change any variable in the Does list. It is the last entry on a choice. On a Change Several Things node it stands under A LASTING CHANGE. The change has the rows of one change of a Set Variable node: the variable with its owner, the operation for a number (+, −, ×, =) and the value. The variable names its owner, so there is no Of row.
It works for the variables of the world, of a scheme, of an actor, a clan, a family or a relationship. A Set Variable node behind the choice is then not needed.
The node Change Several Things has the same kind. The hover text of its Changes list tells the two apart: “Change a variable” changes a number of an actor; “Change any variable” changes a variable of any owner, as Set Variable does. The list also says that a change that cannot be made is skipped and the rest go on.
Decisions and ambitions have the kind too, in their Effects. There is no running scheme there, so a variable of a scheme is refused: the page says a variable of a scheme cannot be changed here: no scheme is running., and a hint under the change says to use a world, actor, clan, family or relationship variable.
Share identical tails
Section titled “Share identical tails”When two branches end with the same nodes, write the end once and link every branch to it. A node can be reached from several outputs, and the nodes after it follow it. Take a Chance whose Success and Failure both go on to the same Add Memory and then the same Succeed Scheme: link both outputs to one Add Memory, instead of a copy on each branch.
Share only nodes that are the same: the same kind with the same settings, leading to the same next nodes. A copy that differs in one value, such as one that adds 1 and one that adds 2, is not the same node.
A shared node is one thing to keep in step. If you change it, both branches change. That is the point of sharing, and also the reason to check that you want both to change.
A shared node has more than one way in, so the Studio draws it as a card, and not as a line under one output. See the reasons in Folding: Then also. Copies on each branch could be lines. A shared tail is one card with two wires. Choose the picture you want to read.
The Studio does not look for identical tails for you. You link them yourself.
How it connects
Section titled “How it connects”You come from Folding: Then also and Node groups, which also make a big scheme shorter to read. Folding and groups change how a scheme is drawn. The tools on this page change the graph, and the scheme does the same. How flows follow links, and what happens when two links lead to one node, is in How a scheme runs. Variables and their owners are in Variables. Dialogue choices are in Dialogues and announcements. Notes and badges are in Problems, notes and validation. Undo is in Copy, paste, duplicate and undo.
Mistakes and messages
Section titled “Mistakes and messages”The command is grey. Nothing you selected starts a run. The node after it may have a comment, another link, a link from another node, more than one output, or a setting of another node that names it, or it may be in another node group. A test run also locks the scheme: the Studio says Stop the run to edit.
I merged and the flow stopped. It did not change. A change that cannot be made stops the flow in a run of separate nodes in the same way.
A Branch By Value never takes my case. A case with the same value as an earlier one never runs. A text has to match exactly. A named choice that is not one of the variable’s choices never matches.
My Check takes the wrong output. Look at Try it, which says whether the conditions hold and why not.
A change of a scheme variable is refused on a decision. A decision runs outside a scheme. Use another owner.
| Message | Where | What it means |
|---|---|---|
| The next node is also a Set Variable. Right-click and choose “Merge into One Set Variable” to make them one node. | Reads as of a Set Variable | Two nodes can be one. An information line, never a problem. |
| Stop the run to edit. | Studio window | A test run plays this scheme and locks it. |
| Add the values to tell apart; everything else goes through Otherwise. | Branch By Value, information line | The node has no case yet. |
| Case 2 has the same value as case 1: it never runs. | Branch By Value, information line | Two cases hold one value. The numbers change. |
| Case 2: ‘Red’ is not one of the variable’s choices. | Branch By Value, error | The case holds a name the variable’s choices do not have. The text changes. |
| Add at least one condition. | Check, error | The list is empty. |
| Condition 2: … and a reason | When the scheme runs | A condition of Check could not be checked. The flow stops. |
| a variable of a scheme cannot be changed here: no scheme is running. | Decisions page and ambitions, error | A decision or an ambition changes a variable of a scheme. |