Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Show text based on choices AND variables - Harlowe

So I've run into a little problem in my game. There is a section where two characters are talking and 4 options pop-up for the player to choose from e.g.
[[Argue point 1 - she is right]]
[[Argue point 1 - she is wrong]]
[[Argue point 2 - she is right]]
[[Argue point 2 - she is wrong]]

Problem one: how do I get the player to be able to see all the choices in that one passage, and once they have made a choice for any of the options, have the alternate choice link disappear e.g. if player chooses Argue point 1 - she is right then the text associated with that passage shows, while Argue point 1 - she is wrong disappears completely.

Note: I would want choice 1 text to stay permanently then on that passage.


Then the player can move on to Argue point 2 - she is right and so on...it doesn't matter in which order they choose Argue points. They could start with 1 or 2 or 3 or 4.

Problem two: I also need a variable set on each of these choices based on the total points you have collected with the girl character. You have been collecting points using:
{(set: $pa +=1)}

So now in this new passage with many choices, I want to be able to increase or decrease your total points with her based on your choice e.g if you choose Argue point 1 - she is right you go up +5 points with the girl.

Problem 3: Once the player has made all his choices on this one passage, can see all of his choices displayed, has scored a certain number of points with the girl character based on the choices, he either gets one response from the girl (if $pa >x) or another response from the girl ($pa <x).

Note: The girl's response would be cumulative of what has happened in the story, not what just happened in the choices in this one passage.

Comments

  • notes:
    a. The following examples will include indenting and extra line-breaks to make them more readable, this will cause unwanted white space between the Argue points. Removing the extra line-breaks will will reduce the unwanted white space.

    b. The following examples includes $variables to track which Argue points were selected and the points with the girl, these $variables need to be assigned a default value before the Passage containing the Argue points is shown. I will be using a startup tagged passage to do this and it will contain the following.
    (set: $point1 to "")
    (set: $point2 to "")
    (set: $point3 to "")
    (set: $point4 to "")
    (set: $pa to 10)
    

    re: Problem 1.
    The following passage allows the selection of four Argue points, notice that the main difference between the code for each of the right/wrong argue point is the name of the $variable and named hook used (eg. point1 vs point2)
    (if: $point1 is "")[
    	|point1>[
    		(link: "Argue point 1 - she is right")[
    			(set: $point1 to "Argue point 1 - she is right")
    			(replace: ?point1)[$point1]
    		]
    		(link: "Argue point 1 - she is wrong")[
    			(set: $point1 to "Argue point 1 - she is wrong")
    			(replace: ?point1)[$point1]
    		]
    	]
    ](else:)[$point1]
    
    (if: $point2 is "")[
    	|point2>[
    		(link: "Argue point 2 - she is right")[
    			(set: $point2 to "Argue point 2 - she is right")
    			(replace: ?point2)[$point2]
    		]
    		(link: "Argue point 2 - she is wrong")[
    			(set: $point2 to "Argue point 2 - she is wrong")
    			(replace: ?point2)[$point2]
    		]
    	]
    ](else:)[$point2]
    
    (if: $point3 is "")[
    	|point3>[
    		(link: "Argue point 3 - she is right")[
    			(set: $point3 to "Argue point 3 - she is right")
    			(replace: ?point3)[$point3]
    		]
    		(link: "Argue point 3 - she is wrong")[
    			(set: $point3 to "Argue point 3 - she is wrong")
    			(replace: ?point3)[$point3]
    		]
    	]
    ](else:)[$point3]
    
    (if: $point4 is "")[
    	|point4>[
    		(link: "Argue point 4 - she is right")[
    			(set: $point4 to "Argue point 4 - she is right")
    			(replace: ?point4)[$point4]
    		]
    		(link: "Argue point 4 - she is wrong")[
    			(set: $point4 to "Argue point 4 - she is wrong")
    			(replace: ?point4)[$point4]
    		]
    	]
    ](else:)[$point4]
    

    re: Problem 2.
    You can add a (set:) macro to the hook of each (link:) macro to change the amount of girl points assigned. So the code for the first Argue point would look something like the following, you can change the code for the second to forth Argue points yourself.
    (if: $point1 is "")[
    	|point1>[
    		(link: "Argue point 1 - she is right")[
    			(set: $point1 to "Argue point 1 - she is right")
    			(set: $pa += 5)
    			(replace: ?point1)[$point1]
    		]
    		(link: "Argue point 1 - she is wrong")[
    			(set: $point1 to "Argue point 1 - she is wrong")
    			(set: $pa -= 5)
    			(replace: ?point1)[$point1]
    		]
    	]
    ](else:)[$point1]
    

    re: Problem 3.
    The solution to this is a little more complex because you need to check the current values of all the $point related variables each time the Reader makes a selection. You could use a (live:) macro to do this but I went with the (display:) macro method.

    a. Create a new passage named Check Selections and place the following in it, it checks the current value of the related variables and uses a (replace:) macro to output the relevant text to a named hook (which will be in the Argue points selection passage)
    (if: $point1 !== "" and $point2 !== "" and $point3 !== "" and $point4 !== "")[
    	(if: $pa > 10)[
    		(replace: ?result)[Text to show if pa was greater than value.]
    	] (else:)[
    		(replace: ?result)[Text to show if pa was NOT greater than value.]
    	]
    ]
    

    b. Change each of the (link:) macros to (display:) the Check Selections passage, the code for the first Argue point would look something like the following, you can change the code for the second to forth Argue points yourself.
    (if: $point1 is "")[
    	|point1>[
    		(link: "Argue point 1 - she is right")[
    			(set: $point1 to "Argue point 1 - she is right")
    			(set: $pa += 5)
    			(replace: ?point1)[$point1]
    			(display: "Check Selections")
    		]
    		(link: "Argue point 1 - she is wrong")[
    			(set: $point1 to "Argue point 1 - she is wrong")
    			(set: $pa -= 5)
    			(replace: ?point1)[$point1]
    			(display: "Check Selections")
    		]
    	]
    ](else:)[$point1]
    

    c. You need to add a named hook so that the (replace:) in the Check Selections passage has somewhere to output the relevant text to. Add the following named hook to the end of the Argue points selection passage.
    |result>[]
    
  • Brilliant! And so well explained I can follow along easily. Thanks as always greyelf.
Sign In or Register to comment.