{"id":130,"date":"2023-02-05T11:53:18","date_gmt":"2023-02-05T16:53:18","guid":{"rendered":"https:\/\/pressbooks.library.torontomu.ca\/playablestoriesink\/?post_type=chapter&#038;p=130"},"modified":"2023-03-03T14:59:27","modified_gmt":"2023-03-03T19:59:27","slug":"chapter-4-labels-and-conditionals","status":"publish","type":"chapter","link":"https:\/\/pressbooks.library.torontomu.ca\/playablestoriesink\/chapter\/chapter-4-labels-and-conditionals\/","title":{"raw":"Chapter 4: Labels and Conditionals","rendered":"Chapter 4: Labels and Conditionals"},"content":{"raw":"<h1><strong>Where are you going? Where have you been?<\/strong><\/h1>\r\nIf the primary unit of a story\u2019s map in Ink is the knot, then the primary unit of the story\u2019s memory is the label.\r\n\r\nBefore proceeding with the lessons in this chapter, take a few minutes to explore the sample scene, \u201c<a href=\"https:\/\/jerrrber.itch.io\/labelling-choices\" target=\"_blank\" rel=\"noopener\">Labelling Choices.<\/a>\u201d As always, play through the short scene more than once. Select the choices in different orders. Do you notice anything different in the text?\r\n\r\nWhen you are finished, download the file (<a href=\"https:\/\/jerrrber.itch.io\/labelling-choices-ink-file\" target=\"_blank\" rel=\"noopener\">Labelling Choices.ink<\/a>) and open it in Inky. We will be referencing this code throughout the lesson.\r\n<div class=\"textbox textbox--learning-objectives\"><header class=\"textbox__header\">\r\n<h1 class=\"textbox__title\">Learning Objectives<\/h1>\r\n<\/header>\r\n<div class=\"textbox__content\">\r\n<ul>\r\n \t<li>To understand labels, and to be able to assign labels using proper command syntax<\/li>\r\n \t<li>To understand basic conditionals, and to be able to create conditionals using proper command syntax<\/li>\r\n \t<li>To demonstrate how labels and conditionals can be used to allow the story to remember the choices the reader has made, making it possible for the story to react accordingly<\/li>\r\n<\/ul>\r\n<\/div>\r\n<\/div>\r\n<h1>Assigning Labels in Ink<\/h1>\r\nA [pb_glossary id=\"279\"]label[\/pb_glossary] is assigned by using an opening and closing parenthesis, for example, \u201c(This_is_a_label).\u201d Label names follow the same conventions as knots and stitches. They may only contain numbers, letters, and underscores; no special symbols or spaces. A label can be assigned to choices and gathers. The label name is placed immediately after the syntax command, and before the text. For example:\r\n<div class=\"textbox shaded\">\r\n<p style=\"padding-left: 40px\">* (this_is_a_label) Labelled Choice<\/p>\r\n<p style=\"padding-left: 40px\">* (this_is_a_different_label) Another Labelled Choice<\/p>\r\n<p style=\"padding-left: 40px\">+ (sticky_choice) A Sticky Choice<\/p>\r\n<p style=\"padding-left: 40px\">- (the_result) The gather to bring the weave back together<\/p>\r\n\r\n<\/div>\r\nEach of the lines above establish either a choice for the reader to select, or a gather for the flow to encounter. When Inky\u2019s flow interacts with any of the above lines, it will also create a label named after the text included between the parentheses.\r\n<h1><strong>Using Labels in Ink<\/strong><\/h1>\r\nLabels, as we shall see, are useful in many different and complex ways. However, a label\u2019s most basic function is as a unit of memory. By assigning a label to a choice or gather point, we tell the story to remember if the reader has made the labelled choice or navigated through the labelled gather. Think of a label as a simple method for instructing the story that \u2018this line is important and to take notes.\u2019\r\n\r\nIn the sample story, \u201cLabelling Choices,\u201d there are several choices presented to the reader, each one beginning with a word set off in parentheses. In Illustration 34 (below), the labels shown are \u201c(rested),\u201d \u201c(bookworm),\u201d \u201c(artsy),\u201d etc. The labels can be any unit of text (as long as they adhere to Ink\u2019s standard naming convention, described above), but it is helpful if the labels are somewhat descriptive to their context, particularly in longer stories or scenes.\r\n\r\nIn this case, the labels have been assigned names that denote characteristics related to the selected choices. Therefore, if the reader selects the option, \u201cExamine the chair,\u201d then the story, internally, activates the label, \u201crested.\u201d If the reader selects \u201cExamine the desk,\u201d the story activates the label \u201ccurious.\u201d\r\n<h1><strong>Conditional Text<\/strong><\/h1>\r\nWith labels in place, we can add conditional elements to the text. Look at lines 13 and 21 in Labelling Choices.ink, shown in Illustration 34 (below).\r\n\r\n&nbsp;\r\n\r\n[caption id=\"attachment_88\" align=\"alignnone\" width=\"754\"]<img src=\"https:\/\/pressbooks.library.torontomu.ca\/playablestoriesink\/wp-content\/uploads\/sites\/363\/2023\/02\/Illustration-34-300x253.png\" alt=\"\" class=\" wp-image-88\" width=\"754\" height=\"636\" \/> Illustration 34. The choices shown above have been assigned the labels (rested), (bookworm), and (artsy)[\/caption]\r\n\r\nThe last sentence of line 13 is set off with beginning and ending curly brackets ( { } ), and begins with the label \u201cbookworm\u201d followed by a colon and some text. The curly brackets introduce a condition that must be met before the line will be displayed in the output. In this case, the label (bookworm) must be activated before the line \u201cYou wish you had grabbed a book after all\u201d will appear.\r\n<h1><strong>Contextual Commands<\/strong><\/h1>\r\nThink back to the section in Chapter 3 on sequences and alternative text. Sequences are also introduced by enclosing them within curly brackets ( { } ). Curly brackets, in general, serve as a signal to Inky that they include instructions that must be followed. However, Inky is able to understand those instructions based on the context in which they are presented. Because \u201cbookworm\u201d has already been introduced as a label (see line 19) and is followed by a colon, when Inky parses the information in line 13\u2014interprets it in real time\u2014it instructs the story to only print the text within the brackets if the label \u201cbookworm\u201d has been activated (that is, if the reader has previously selected the \u201cexamine the bookshelf\u201d choice on line 19, which has the (bookworm) label). In this way, you can control the output the reader sees from the current flow. The text at the end of line 13\u2014\u201dYou wish you had grabbed a book after all\u201d\u2014only makes sense within the story if the reader has selected \u201cExamine the bookshelf\u201d before selecting \u201cExamine the chair.\u201d\r\n\r\nLooking at line 21, we see two sets of curly brackets. One begins with the label \u201crested,\u201d and the other begins with \u201cnot rested.\u201d Ink understands the word \u201cnot,\u201d which allows us to give the more specific instruction to print the text within the brackets only if the label \u201crested\u201d has not been activated (that is, that the reader has not yet selected the choice \u201cexamine the chair\u201d on line 11, which has the (rested) label). Note how the context of the two bracketed sentences changes based on whether or not the reader has first selected \u201cExamine the chair.\u201d Using this technique, you can write sentences that anticipate each of the potential choices your reader might make while simultaneously instructing Inky to display only the text that correctly corresponds to the reader\u2019s choice.\r\n\r\nInky also has a short-hand method for including both options\u2014{exampleLabel: display this text} and {not exampleLabel: display this text}\u2014within a single command. For example, look at line 39 shown in Illustration 35 (below). The bracketed portion reads:\r\n<p style=\"padding-left: 40px\">{curious: trying to forget the mess on the desk below. | trying to avoid looking at the desk below.}<\/p>\r\n&nbsp;\r\n\r\n[caption id=\"attachment_89\" align=\"alignnone\" width=\"752\"]<img src=\"https:\/\/pressbooks.library.torontomu.ca\/playablestoriesink\/wp-content\/uploads\/sites\/363\/2023\/02\/Illustration-35-300x185.png\" alt=\"\" class=\" wp-image-89\" width=\"752\" height=\"464\" \/> Illustration 35. More choices that have been assigned labels. The text on lines 33 and 39 contains conditional text, set apart by curly brackets.[\/caption]\r\n\r\nBy separating the two sets of text within the brackets with the vertical slash ( | ), we instruct Ink that if the label \u201ccurious\u201d has been activated, it is to show the first set of text. Otherwise, it should show the second set. This shorthand method produces the same result as listing two separate sets of brackets, one with instructions for \u201ccurious,\u201d and one with instructions for \u201cnot curious.\u201d It is yet another example of the ways Inky is capable of parsing the instructions contained by the curly brackets based on multiple contexts.\r\n<div class=\"textbox shaded\">\r\n\r\n<strong>Inky at Work:\u00a0<\/strong>Labels are a powerful tool in Inky, and we are going to expand on their usefulness and complexity in the coming sections. However, as we do, remember how simply and elegantly labels can be used as well. One of the most convenient advantages labels afford a writer in Inky is the ability to quickly add a phrase or alter a line of dialogue for a certain story flow or thread.\r\n\r\nAdditionally, labels are easy to add at any point during the writing. For example, if you decide, toward the end of your editing process, that you want your characters to treat the player\/reader differently if the player decides to, say, share their lunch with the new kid, simply add a label to that choice, such as (shared). Then, as you go through the story, it is easy to add any additional text or dialogue you would like with {shared: new text}.\r\n\r\n<\/div>\r\n<h1><strong>Some Advanced Logic<\/strong><\/h1>\r\nThe final choice available to the reader, shown in lines 43-50 in Illustration 36 (below), demonstrates something else made possible through the use of labels. When a label is triggered, Inky is not only remembering whether or not that choice has been selected. It is also remembering how many times that choice has been selected.\r\n\r\n&nbsp;\r\n\r\n[caption id=\"attachment_90\" align=\"alignnone\" width=\"755\"]<img src=\"https:\/\/pressbooks.library.torontomu.ca\/playablestoriesink\/wp-content\/uploads\/sites\/363\/2023\/02\/Illustration-36-300x87.png\" alt=\"\" class=\" wp-image-90\" width=\"755\" height=\"219\" \/> Illustration 36. Code demonstrating conditional text based on the number of times a label has been activated[\/caption]\r\n\r\nNote that the choice on line 43 is a sticky choice, marked by a \u201c + \u201c. When the reader selects \u201c[Leave the room]\u201d, the label \u201c(anxious)\u201d is activated. The flow then continues on to line 45, which contains a default sequence of 4 pieces of alternative text. As we learned in the previous section, Inky will present the alternatives in order, one at a time, each subsequent time the sticky choice is selected. Therefore, the first time [Leave the room] is selected, Inky prints \u201cThat would be easier if you could somehow locate a door,\u201d then the flow continues to line 47.\r\n<h1><strong>Inky Can Count<\/strong><\/h1>\r\nLine 47 reads:\r\n<p style=\"padding-left: 40px\">{anxious &gt; 3: -&gt; Conclusion}<\/p>\r\nThis looks very similar to the previous instructions to check for an activated label; in this case, the label is \u201c(anxious)\u201d. However, the label is followed by the greater-than symbol and the numeral three, \u201c &gt; 3 \u201c. The line concludes with a divert to a knot called \u201cConclusion\u201d.\r\n\r\nLine 47, if written out as a sentence, would say something along the lines of, \u201cIf (anxious) has been visited more than three times, then go to ===Conclusion===\u201d. What Inky does is evaluate this line to determine if it is \u2018true\u2019 or \u2018false.\u2019 If the line evaluates as (false), it is not activated. It will only activate statements that are (true).\r\n\r\nBecause (anxious) has now been selected only once, the statement on line 47 evaluates as (false) and the flow proceeds to lines 48 and 49. (Anxious) has still only been selected once, so the instructions for \u201c &gt; 2 \u201d and \u201c &gt; 1 \u201c are passed for now since both evaluate to (false) as well. The flow continues to line 50, which contains instructions to divert back to the knot \u201cRoom\u201d, which refreshes the remaining choices.\r\n\r\nBecause the choice [Leave the room] is a sticky choice, it is available to be selected again. Doing so will activate the label (anxious) for the second time. The flow will then proceed to print the second alternative text from the sequence on line 45, as it is the second time the sequence has been visited.\r\n\r\nBecause it has been selected twice, Inky increases the label (anxious) to a value of 2, so for now the flow will still bypass lines 47 and 48, which still evaluate to (false). Line 49 checks if the label (anxious) is greater than 1. It is (true), so the text on line 49 is printed to the output. Line 49 ends with instructions to return to the knot, \u201cRoom.\u201d\r\n\r\nIllustration 37 (below) shows the output if \u201c[Leave the room]\u201d is selected 4 consecutive times. See if you can match the printed lines to the instructions listed in lines 43-50.\r\n\r\n&nbsp;\r\n\r\n[caption id=\"attachment_91\" align=\"alignnone\" width=\"755\"]<img src=\"https:\/\/pressbooks.library.torontomu.ca\/playablestoriesink\/wp-content\/uploads\/sites\/363\/2023\/02\/Illustration-37-300x244.png\" alt=\"\" class=\" wp-image-91\" width=\"755\" height=\"614\" \/> Illustration 37. Various output resulting from selecting the choice \u201c[Leave the room]\u201d[\/caption]\r\n<h1><strong>Many Possible Texts<\/strong><\/h1>\r\nThis simple sample scene provides for numerous variations in the ways the text could potentially be presented to the reader. For example, there are little details that change based on the order in which the choices are selected. It is possible for the scene to end without every choice even having been selected. The sticky choice, \u201c[Leave the room],\u201d need not be selected consecutively. Although it might be, if the reader exhausts all of the other options first, before attempting to leave. You are writing a potential story\u2014what particular version will emerge will be determined by your readers. By using labels and some simple conditionals, you are instructing Inky how to weave the text together.\r\n<div class=\"textbox textbox--key-takeaways\"><header class=\"textbox__header\">\r\n<h1 class=\"textbox__title\">Review<\/h1>\r\n<\/header>\r\n<div class=\"textbox__content\">\r\n<ul>\r\n \t<li>In this chapter, we have learned that labels are a basic unit of information that can be tracked by an Ink story, and we have learned how to assign a label to a choice or a gather by using parentheses, ( ).<\/li>\r\n \t<li>We have also learned how to introduce conditional instructions by using curly brackets containing contextual commands, which Inky can then parse, or interpret, in order to present the story in a manner consistent with the decisions the reader makes. By using labels and conditionals, you can write a story that not only keeps track of the reader\u2019s position in a web of nodes; it also keeps track of the route the reader takes and the decisions they make along the way.<\/li>\r\n \t<li>We also introduced the use of greater-than signs as a unit of logic that checks the number of times a label has been selected. In the next chapter, we will explore other logic commands, adding greater complexity to the instructions we write.<\/li>\r\n<\/ul>\r\n<\/div>\r\n<\/div>\r\n<h1>Putting It All Together<\/h1>\r\nThe sample story presented in this chapter illustrates a scene that takes place in primarily a single knot, but still presents multiple possible presentations of the available text.\r\n\r\nTake some time to experiment with this form for an Ink story. It represents a template that can be used for any scene or story that involves exploration or investigation within a single location. By assigning labels to the available choices, it becomes easy to adjust the text that is ultimately output based on what the reader has already discovered. By using a combination of basic and sticky choices, coupled with sequences of alternative text and logic instructions, you can write a scene that allows for multiple variations of the text while it slowly tightens the weave, funnelling the reader to either an ending or a passage into the next scene.\r\n<div class=\"textbox shaded\">\r\n\r\n<span style=\"color: #ff0000\"><strong>IMPORTANT REMINDER!<\/strong> <\/span>(Because the techniques in this chapter often require the use of recursive diverts that direct the flow back to the same knot, keep in mind this warning from Chapter 2) Do not create any infinite loops! In a scene such as this, which continuously diverts back onto itself, it is ridiculously important to remember to NOT EVER delete the choice text between the name of the knot and the first divert.\r\n\r\nInky will allow you to write:\r\n<p style=\"padding-left: 40px\">1 ===infiniteLoop===<\/p>\r\n<p style=\"padding-left: 40px\">2 -&gt; infiniteLoop<\/p>\r\nThis will immediately put Inky into an infinite loop, with the knot diverting back into itself over and over again forever until you can use your computer\u2019s task manager to Force Quit the program. Your story, if unsaved, will be unrecoverable.\r\n\r\nThis can happen quite accidentally during the editing process if the writer removes the first choice in the knot, having decided to re-write it, unintentionally leaving no text between the name of the knot and the first divert back to the top of the loop. This advice may be inspired by true events. Save often, and stay away from infinite loops.\r\n\r\n<\/div>\r\n<span style=\"text-align: initial;font-size: 1em\">In the next chapter, we will introduce variables and expand our set of logic commands, making for stories that include even more complex sets of instructions!<\/span>","rendered":"<h1><strong>Where are you going? Where have you been?<\/strong><\/h1>\n<p>If the primary unit of a story\u2019s map in Ink is the knot, then the primary unit of the story\u2019s memory is the label.<\/p>\n<p>Before proceeding with the lessons in this chapter, take a few minutes to explore the sample scene, \u201c<a href=\"https:\/\/jerrrber.itch.io\/labelling-choices\" target=\"_blank\" rel=\"noopener\">Labelling Choices.<\/a>\u201d As always, play through the short scene more than once. Select the choices in different orders. Do you notice anything different in the text?<\/p>\n<p>When you are finished, download the file (<a href=\"https:\/\/jerrrber.itch.io\/labelling-choices-ink-file\" target=\"_blank\" rel=\"noopener\">Labelling Choices.ink<\/a>) and open it in Inky. We will be referencing this code throughout the lesson.<\/p>\n<div class=\"textbox textbox--learning-objectives\">\n<header class=\"textbox__header\">\n<h1 class=\"textbox__title\">Learning Objectives<\/h1>\n<\/header>\n<div class=\"textbox__content\">\n<ul>\n<li>To understand labels, and to be able to assign labels using proper command syntax<\/li>\n<li>To understand basic conditionals, and to be able to create conditionals using proper command syntax<\/li>\n<li>To demonstrate how labels and conditionals can be used to allow the story to remember the choices the reader has made, making it possible for the story to react accordingly<\/li>\n<\/ul>\n<\/div>\n<\/div>\n<h1>Assigning Labels in Ink<\/h1>\n<p>A <button class=\"glossary-term\" aria-describedby=\"130-279\">label<\/button> is assigned by using an opening and closing parenthesis, for example, \u201c(This_is_a_label).\u201d Label names follow the same conventions as knots and stitches. They may only contain numbers, letters, and underscores; no special symbols or spaces. A label can be assigned to choices and gathers. The label name is placed immediately after the syntax command, and before the text. For example:<\/p>\n<div class=\"textbox shaded\">\n<p style=\"padding-left: 40px\">* (this_is_a_label) Labelled Choice<\/p>\n<p style=\"padding-left: 40px\">* (this_is_a_different_label) Another Labelled Choice<\/p>\n<p style=\"padding-left: 40px\">+ (sticky_choice) A Sticky Choice<\/p>\n<p style=\"padding-left: 40px\">&#8211; (the_result) The gather to bring the weave back together<\/p>\n<\/div>\n<p>Each of the lines above establish either a choice for the reader to select, or a gather for the flow to encounter. When Inky\u2019s flow interacts with any of the above lines, it will also create a label named after the text included between the parentheses.<\/p>\n<h1><strong>Using Labels in Ink<\/strong><\/h1>\n<p>Labels, as we shall see, are useful in many different and complex ways. However, a label\u2019s most basic function is as a unit of memory. By assigning a label to a choice or gather point, we tell the story to remember if the reader has made the labelled choice or navigated through the labelled gather. Think of a label as a simple method for instructing the story that \u2018this line is important and to take notes.\u2019<\/p>\n<p>In the sample story, \u201cLabelling Choices,\u201d there are several choices presented to the reader, each one beginning with a word set off in parentheses. In Illustration 34 (below), the labels shown are \u201c(rested),\u201d \u201c(bookworm),\u201d \u201c(artsy),\u201d etc. The labels can be any unit of text (as long as they adhere to Ink\u2019s standard naming convention, described above), but it is helpful if the labels are somewhat descriptive to their context, particularly in longer stories or scenes.<\/p>\n<p>In this case, the labels have been assigned names that denote characteristics related to the selected choices. Therefore, if the reader selects the option, \u201cExamine the chair,\u201d then the story, internally, activates the label, \u201crested.\u201d If the reader selects \u201cExamine the desk,\u201d the story activates the label \u201ccurious.\u201d<\/p>\n<h1><strong>Conditional Text<\/strong><\/h1>\n<p>With labels in place, we can add conditional elements to the text. Look at lines 13 and 21 in Labelling Choices.ink, shown in Illustration 34 (below).<\/p>\n<p>&nbsp;<\/p>\n<figure id=\"attachment_88\" aria-describedby=\"caption-attachment-88\" style=\"width: 754px\" class=\"wp-caption alignnone\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/pressbooks.library.torontomu.ca\/playablestoriesink\/wp-content\/uploads\/sites\/363\/2023\/02\/Illustration-34-300x253.png\" alt=\"\" class=\"wp-image-88\" width=\"754\" height=\"636\" srcset=\"https:\/\/pressbooks.library.torontomu.ca\/playablestoriesink\/wp-content\/uploads\/sites\/363\/2023\/02\/Illustration-34-300x253.png 300w, https:\/\/pressbooks.library.torontomu.ca\/playablestoriesink\/wp-content\/uploads\/sites\/363\/2023\/02\/Illustration-34-1024x865.png 1024w, https:\/\/pressbooks.library.torontomu.ca\/playablestoriesink\/wp-content\/uploads\/sites\/363\/2023\/02\/Illustration-34-768x649.png 768w, https:\/\/pressbooks.library.torontomu.ca\/playablestoriesink\/wp-content\/uploads\/sites\/363\/2023\/02\/Illustration-34-65x55.png 65w, https:\/\/pressbooks.library.torontomu.ca\/playablestoriesink\/wp-content\/uploads\/sites\/363\/2023\/02\/Illustration-34-225x190.png 225w, https:\/\/pressbooks.library.torontomu.ca\/playablestoriesink\/wp-content\/uploads\/sites\/363\/2023\/02\/Illustration-34-350x296.png 350w, https:\/\/pressbooks.library.torontomu.ca\/playablestoriesink\/wp-content\/uploads\/sites\/363\/2023\/02\/Illustration-34.png 1326w\" sizes=\"auto, (max-width: 754px) 100vw, 754px\" \/><figcaption id=\"caption-attachment-88\" class=\"wp-caption-text\">Illustration 34. The choices shown above have been assigned the labels (rested), (bookworm), and (artsy)<\/figcaption><\/figure>\n<p>The last sentence of line 13 is set off with beginning and ending curly brackets ( { } ), and begins with the label \u201cbookworm\u201d followed by a colon and some text. The curly brackets introduce a condition that must be met before the line will be displayed in the output. In this case, the label (bookworm) must be activated before the line \u201cYou wish you had grabbed a book after all\u201d will appear.<\/p>\n<h1><strong>Contextual Commands<\/strong><\/h1>\n<p>Think back to the section in Chapter 3 on sequences and alternative text. Sequences are also introduced by enclosing them within curly brackets ( { } ). Curly brackets, in general, serve as a signal to Inky that they include instructions that must be followed. However, Inky is able to understand those instructions based on the context in which they are presented. Because \u201cbookworm\u201d has already been introduced as a label (see line 19) and is followed by a colon, when Inky parses the information in line 13\u2014interprets it in real time\u2014it instructs the story to only print the text within the brackets if the label \u201cbookworm\u201d has been activated (that is, if the reader has previously selected the \u201cexamine the bookshelf\u201d choice on line 19, which has the (bookworm) label). In this way, you can control the output the reader sees from the current flow. The text at the end of line 13\u2014\u201dYou wish you had grabbed a book after all\u201d\u2014only makes sense within the story if the reader has selected \u201cExamine the bookshelf\u201d before selecting \u201cExamine the chair.\u201d<\/p>\n<p>Looking at line 21, we see two sets of curly brackets. One begins with the label \u201crested,\u201d and the other begins with \u201cnot rested.\u201d Ink understands the word \u201cnot,\u201d which allows us to give the more specific instruction to print the text within the brackets only if the label \u201crested\u201d has not been activated (that is, that the reader has not yet selected the choice \u201cexamine the chair\u201d on line 11, which has the (rested) label). Note how the context of the two bracketed sentences changes based on whether or not the reader has first selected \u201cExamine the chair.\u201d Using this technique, you can write sentences that anticipate each of the potential choices your reader might make while simultaneously instructing Inky to display only the text that correctly corresponds to the reader\u2019s choice.<\/p>\n<p>Inky also has a short-hand method for including both options\u2014{exampleLabel: display this text} and {not exampleLabel: display this text}\u2014within a single command. For example, look at line 39 shown in Illustration 35 (below). The bracketed portion reads:<\/p>\n<p style=\"padding-left: 40px\">{curious: trying to forget the mess on the desk below. | trying to avoid looking at the desk below.}<\/p>\n<p>&nbsp;<\/p>\n<figure id=\"attachment_89\" aria-describedby=\"caption-attachment-89\" style=\"width: 752px\" class=\"wp-caption alignnone\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/pressbooks.library.torontomu.ca\/playablestoriesink\/wp-content\/uploads\/sites\/363\/2023\/02\/Illustration-35-300x185.png\" alt=\"\" class=\"wp-image-89\" width=\"752\" height=\"464\" srcset=\"https:\/\/pressbooks.library.torontomu.ca\/playablestoriesink\/wp-content\/uploads\/sites\/363\/2023\/02\/Illustration-35-300x185.png 300w, https:\/\/pressbooks.library.torontomu.ca\/playablestoriesink\/wp-content\/uploads\/sites\/363\/2023\/02\/Illustration-35-1024x631.png 1024w, https:\/\/pressbooks.library.torontomu.ca\/playablestoriesink\/wp-content\/uploads\/sites\/363\/2023\/02\/Illustration-35-768x473.png 768w, https:\/\/pressbooks.library.torontomu.ca\/playablestoriesink\/wp-content\/uploads\/sites\/363\/2023\/02\/Illustration-35-65x40.png 65w, https:\/\/pressbooks.library.torontomu.ca\/playablestoriesink\/wp-content\/uploads\/sites\/363\/2023\/02\/Illustration-35-225x139.png 225w, https:\/\/pressbooks.library.torontomu.ca\/playablestoriesink\/wp-content\/uploads\/sites\/363\/2023\/02\/Illustration-35-350x216.png 350w, https:\/\/pressbooks.library.torontomu.ca\/playablestoriesink\/wp-content\/uploads\/sites\/363\/2023\/02\/Illustration-35.png 1314w\" sizes=\"auto, (max-width: 752px) 100vw, 752px\" \/><figcaption id=\"caption-attachment-89\" class=\"wp-caption-text\">Illustration 35. More choices that have been assigned labels. The text on lines 33 and 39 contains conditional text, set apart by curly brackets.<\/figcaption><\/figure>\n<p>By separating the two sets of text within the brackets with the vertical slash ( | ), we instruct Ink that if the label \u201ccurious\u201d has been activated, it is to show the first set of text. Otherwise, it should show the second set. This shorthand method produces the same result as listing two separate sets of brackets, one with instructions for \u201ccurious,\u201d and one with instructions for \u201cnot curious.\u201d It is yet another example of the ways Inky is capable of parsing the instructions contained by the curly brackets based on multiple contexts.<\/p>\n<div class=\"textbox shaded\">\n<p><strong>Inky at Work:\u00a0<\/strong>Labels are a powerful tool in Inky, and we are going to expand on their usefulness and complexity in the coming sections. However, as we do, remember how simply and elegantly labels can be used as well. One of the most convenient advantages labels afford a writer in Inky is the ability to quickly add a phrase or alter a line of dialogue for a certain story flow or thread.<\/p>\n<p>Additionally, labels are easy to add at any point during the writing. For example, if you decide, toward the end of your editing process, that you want your characters to treat the player\/reader differently if the player decides to, say, share their lunch with the new kid, simply add a label to that choice, such as (shared). Then, as you go through the story, it is easy to add any additional text or dialogue you would like with {shared: new text}.<\/p>\n<\/div>\n<h1><strong>Some Advanced Logic<\/strong><\/h1>\n<p>The final choice available to the reader, shown in lines 43-50 in Illustration 36 (below), demonstrates something else made possible through the use of labels. When a label is triggered, Inky is not only remembering whether or not that choice has been selected. It is also remembering how many times that choice has been selected.<\/p>\n<p>&nbsp;<\/p>\n<figure id=\"attachment_90\" aria-describedby=\"caption-attachment-90\" style=\"width: 755px\" class=\"wp-caption alignnone\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/pressbooks.library.torontomu.ca\/playablestoriesink\/wp-content\/uploads\/sites\/363\/2023\/02\/Illustration-36-300x87.png\" alt=\"\" class=\"wp-image-90\" width=\"755\" height=\"219\" srcset=\"https:\/\/pressbooks.library.torontomu.ca\/playablestoriesink\/wp-content\/uploads\/sites\/363\/2023\/02\/Illustration-36-300x87.png 300w, https:\/\/pressbooks.library.torontomu.ca\/playablestoriesink\/wp-content\/uploads\/sites\/363\/2023\/02\/Illustration-36-1024x298.png 1024w, https:\/\/pressbooks.library.torontomu.ca\/playablestoriesink\/wp-content\/uploads\/sites\/363\/2023\/02\/Illustration-36-768x224.png 768w, https:\/\/pressbooks.library.torontomu.ca\/playablestoriesink\/wp-content\/uploads\/sites\/363\/2023\/02\/Illustration-36-65x19.png 65w, https:\/\/pressbooks.library.torontomu.ca\/playablestoriesink\/wp-content\/uploads\/sites\/363\/2023\/02\/Illustration-36-225x66.png 225w, https:\/\/pressbooks.library.torontomu.ca\/playablestoriesink\/wp-content\/uploads\/sites\/363\/2023\/02\/Illustration-36-350x102.png 350w, https:\/\/pressbooks.library.torontomu.ca\/playablestoriesink\/wp-content\/uploads\/sites\/363\/2023\/02\/Illustration-36.png 1256w\" sizes=\"auto, (max-width: 755px) 100vw, 755px\" \/><figcaption id=\"caption-attachment-90\" class=\"wp-caption-text\">Illustration 36. Code demonstrating conditional text based on the number of times a label has been activated<\/figcaption><\/figure>\n<p>Note that the choice on line 43 is a sticky choice, marked by a \u201c + \u201c. When the reader selects \u201c[Leave the room]\u201d, the label \u201c(anxious)\u201d is activated. The flow then continues on to line 45, which contains a default sequence of 4 pieces of alternative text. As we learned in the previous section, Inky will present the alternatives in order, one at a time, each subsequent time the sticky choice is selected. Therefore, the first time [Leave the room] is selected, Inky prints \u201cThat would be easier if you could somehow locate a door,\u201d then the flow continues to line 47.<\/p>\n<h1><strong>Inky Can Count<\/strong><\/h1>\n<p>Line 47 reads:<\/p>\n<p style=\"padding-left: 40px\">{anxious &gt; 3: -&gt; Conclusion}<\/p>\n<p>This looks very similar to the previous instructions to check for an activated label; in this case, the label is \u201c(anxious)\u201d. However, the label is followed by the greater-than symbol and the numeral three, \u201c &gt; 3 \u201c. The line concludes with a divert to a knot called \u201cConclusion\u201d.<\/p>\n<p>Line 47, if written out as a sentence, would say something along the lines of, \u201cIf (anxious) has been visited more than three times, then go to ===Conclusion===\u201d. What Inky does is evaluate this line to determine if it is \u2018true\u2019 or \u2018false.\u2019 If the line evaluates as (false), it is not activated. It will only activate statements that are (true).<\/p>\n<p>Because (anxious) has now been selected only once, the statement on line 47 evaluates as (false) and the flow proceeds to lines 48 and 49. (Anxious) has still only been selected once, so the instructions for \u201c &gt; 2 \u201d and \u201c &gt; 1 \u201c are passed for now since both evaluate to (false) as well. The flow continues to line 50, which contains instructions to divert back to the knot \u201cRoom\u201d, which refreshes the remaining choices.<\/p>\n<p>Because the choice [Leave the room] is a sticky choice, it is available to be selected again. Doing so will activate the label (anxious) for the second time. The flow will then proceed to print the second alternative text from the sequence on line 45, as it is the second time the sequence has been visited.<\/p>\n<p>Because it has been selected twice, Inky increases the label (anxious) to a value of 2, so for now the flow will still bypass lines 47 and 48, which still evaluate to (false). Line 49 checks if the label (anxious) is greater than 1. It is (true), so the text on line 49 is printed to the output. Line 49 ends with instructions to return to the knot, \u201cRoom.\u201d<\/p>\n<p>Illustration 37 (below) shows the output if \u201c[Leave the room]\u201d is selected 4 consecutive times. See if you can match the printed lines to the instructions listed in lines 43-50.<\/p>\n<p>&nbsp;<\/p>\n<figure id=\"attachment_91\" aria-describedby=\"caption-attachment-91\" style=\"width: 755px\" class=\"wp-caption alignnone\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/pressbooks.library.torontomu.ca\/playablestoriesink\/wp-content\/uploads\/sites\/363\/2023\/02\/Illustration-37-300x244.png\" alt=\"\" class=\"wp-image-91\" width=\"755\" height=\"614\" srcset=\"https:\/\/pressbooks.library.torontomu.ca\/playablestoriesink\/wp-content\/uploads\/sites\/363\/2023\/02\/Illustration-37-300x244.png 300w, https:\/\/pressbooks.library.torontomu.ca\/playablestoriesink\/wp-content\/uploads\/sites\/363\/2023\/02\/Illustration-37-1024x832.png 1024w, https:\/\/pressbooks.library.torontomu.ca\/playablestoriesink\/wp-content\/uploads\/sites\/363\/2023\/02\/Illustration-37-768x624.png 768w, https:\/\/pressbooks.library.torontomu.ca\/playablestoriesink\/wp-content\/uploads\/sites\/363\/2023\/02\/Illustration-37-65x53.png 65w, https:\/\/pressbooks.library.torontomu.ca\/playablestoriesink\/wp-content\/uploads\/sites\/363\/2023\/02\/Illustration-37-225x183.png 225w, https:\/\/pressbooks.library.torontomu.ca\/playablestoriesink\/wp-content\/uploads\/sites\/363\/2023\/02\/Illustration-37-350x284.png 350w, https:\/\/pressbooks.library.torontomu.ca\/playablestoriesink\/wp-content\/uploads\/sites\/363\/2023\/02\/Illustration-37.png 1194w\" sizes=\"auto, (max-width: 755px) 100vw, 755px\" \/><figcaption id=\"caption-attachment-91\" class=\"wp-caption-text\">Illustration 37. Various output resulting from selecting the choice \u201c[Leave the room]\u201d<\/figcaption><\/figure>\n<h1><strong>Many Possible Texts<\/strong><\/h1>\n<p>This simple sample scene provides for numerous variations in the ways the text could potentially be presented to the reader. For example, there are little details that change based on the order in which the choices are selected. It is possible for the scene to end without every choice even having been selected. The sticky choice, \u201c[Leave the room],\u201d need not be selected consecutively. Although it might be, if the reader exhausts all of the other options first, before attempting to leave. You are writing a potential story\u2014what particular version will emerge will be determined by your readers. By using labels and some simple conditionals, you are instructing Inky how to weave the text together.<\/p>\n<div class=\"textbox textbox--key-takeaways\">\n<header class=\"textbox__header\">\n<h1 class=\"textbox__title\">Review<\/h1>\n<\/header>\n<div class=\"textbox__content\">\n<ul>\n<li>In this chapter, we have learned that labels are a basic unit of information that can be tracked by an Ink story, and we have learned how to assign a label to a choice or a gather by using parentheses, ( ).<\/li>\n<li>We have also learned how to introduce conditional instructions by using curly brackets containing contextual commands, which Inky can then parse, or interpret, in order to present the story in a manner consistent with the decisions the reader makes. By using labels and conditionals, you can write a story that not only keeps track of the reader\u2019s position in a web of nodes; it also keeps track of the route the reader takes and the decisions they make along the way.<\/li>\n<li>We also introduced the use of greater-than signs as a unit of logic that checks the number of times a label has been selected. In the next chapter, we will explore other logic commands, adding greater complexity to the instructions we write.<\/li>\n<\/ul>\n<\/div>\n<\/div>\n<h1>Putting It All Together<\/h1>\n<p>The sample story presented in this chapter illustrates a scene that takes place in primarily a single knot, but still presents multiple possible presentations of the available text.<\/p>\n<p>Take some time to experiment with this form for an Ink story. It represents a template that can be used for any scene or story that involves exploration or investigation within a single location. By assigning labels to the available choices, it becomes easy to adjust the text that is ultimately output based on what the reader has already discovered. By using a combination of basic and sticky choices, coupled with sequences of alternative text and logic instructions, you can write a scene that allows for multiple variations of the text while it slowly tightens the weave, funnelling the reader to either an ending or a passage into the next scene.<\/p>\n<div class=\"textbox shaded\">\n<p><span style=\"color: #ff0000\"><strong>IMPORTANT REMINDER!<\/strong> <\/span>(Because the techniques in this chapter often require the use of recursive diverts that direct the flow back to the same knot, keep in mind this warning from Chapter 2) Do not create any infinite loops! In a scene such as this, which continuously diverts back onto itself, it is ridiculously important to remember to NOT EVER delete the choice text between the name of the knot and the first divert.<\/p>\n<p>Inky will allow you to write:<\/p>\n<p style=\"padding-left: 40px\">1 ===infiniteLoop===<\/p>\n<p style=\"padding-left: 40px\">2 -&gt; infiniteLoop<\/p>\n<p>This will immediately put Inky into an infinite loop, with the knot diverting back into itself over and over again forever until you can use your computer\u2019s task manager to Force Quit the program. Your story, if unsaved, will be unrecoverable.<\/p>\n<p>This can happen quite accidentally during the editing process if the writer removes the first choice in the knot, having decided to re-write it, unintentionally leaving no text between the name of the knot and the first divert back to the top of the loop. This advice may be inspired by true events. Save often, and stay away from infinite loops.<\/p>\n<\/div>\n<p><span style=\"text-align: initial;font-size: 1em\">In the next chapter, we will introduce variables and expand our set of logic commands, making for stories that include even more complex sets of instructions!<\/span><\/p>\n<div class=\"glossary\"><div class=\"glossary__tooltip\" id=\"130-279\" hidden><p>Think of a label as exactly that, it is a tag, a reminder that the Ink story's flow has passed through the thread<\/p>\n<\/div><\/div>","protected":false},"author":464,"menu_order":1,"template":"","meta":{"pb_show_title":"on","pb_short_title":"","pb_subtitle":"","pb_authors":[],"pb_section_license":""},"chapter-type":[49],"contributor":[],"license":[],"class_list":["post-130","chapter","type-chapter","status-publish","hentry","chapter-type-numberless"],"part":128,"_links":{"self":[{"href":"https:\/\/pressbooks.library.torontomu.ca\/playablestoriesink\/wp-json\/pressbooks\/v2\/chapters\/130","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/pressbooks.library.torontomu.ca\/playablestoriesink\/wp-json\/pressbooks\/v2\/chapters"}],"about":[{"href":"https:\/\/pressbooks.library.torontomu.ca\/playablestoriesink\/wp-json\/wp\/v2\/types\/chapter"}],"author":[{"embeddable":true,"href":"https:\/\/pressbooks.library.torontomu.ca\/playablestoriesink\/wp-json\/wp\/v2\/users\/464"}],"version-history":[{"count":11,"href":"https:\/\/pressbooks.library.torontomu.ca\/playablestoriesink\/wp-json\/pressbooks\/v2\/chapters\/130\/revisions"}],"predecessor-version":[{"id":294,"href":"https:\/\/pressbooks.library.torontomu.ca\/playablestoriesink\/wp-json\/pressbooks\/v2\/chapters\/130\/revisions\/294"}],"part":[{"href":"https:\/\/pressbooks.library.torontomu.ca\/playablestoriesink\/wp-json\/pressbooks\/v2\/parts\/128"}],"metadata":[{"href":"https:\/\/pressbooks.library.torontomu.ca\/playablestoriesink\/wp-json\/pressbooks\/v2\/chapters\/130\/metadata\/"}],"wp:attachment":[{"href":"https:\/\/pressbooks.library.torontomu.ca\/playablestoriesink\/wp-json\/wp\/v2\/media?parent=130"}],"wp:term":[{"taxonomy":"chapter-type","embeddable":true,"href":"https:\/\/pressbooks.library.torontomu.ca\/playablestoriesink\/wp-json\/pressbooks\/v2\/chapter-type?post=130"},{"taxonomy":"contributor","embeddable":true,"href":"https:\/\/pressbooks.library.torontomu.ca\/playablestoriesink\/wp-json\/wp\/v2\/contributor?post=130"},{"taxonomy":"license","embeddable":true,"href":"https:\/\/pressbooks.library.torontomu.ca\/playablestoriesink\/wp-json\/wp\/v2\/license?post=130"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}