To elaborate on what P.B. said at the end there, having both <<textarea>>
macros set the same variable could cause problems, since then that variable will get set to the text in whichever one of those <<textarea>>
s was last edited, regardless of which button you pushed.
Thus, I’d change the code to something like this:
What do you think?
People should’ve continued to do that because:
<<textarea "_should" "Type your answer here">>
<<button "Submit" "Next Passage Name">>
<<set $response = _should>>
<</button>>
People shouldn't have done that because:
<<textarea "_not" "Type your answer here">>
<<button "Submit" "Next Passage Name">>
<<set $response = _not>>
<</button>>
By setting two different temporary variables, and then assigning the value from the temporary variable related to the button the user clicked to the $response story variable, that would prevent the wrong text from being submitted.
Also note that you can combine the <<button>>
and <<goto>>
macros, simply by setting the second parameter of the <<button>>
macro to the name of the passage you want to go to. (So, you’ll need to change “Next Passage Name
” to the name of the passage you want to send the player to when they click those buttons.)
You may also want to label the response, so you can tell which button was clicked. For example, you could do something like this instead:
<<set $response = "Should: " + _should>>
...
<<set $response = "Should not: " + _not>>
Now you’ll be able to easily tell which <<textarea>>
the value of $response comes from.
Note: I also removed the <span>
stuff from the code, since it didn’t appear to be implemented correctly. If you want both of those answer areas to be affected by some CSS, then, instead of using an ID, you should use a class on those spans. IDs are supposed to be unique on the page, but multiple HTML elements can all have the same class at the same time. If you change your CSS from “#output
” (i.e. ID = "output) to “.output
” (class = “output”), then you could do this instead:
What do you think?
<span class="output">\
People should’ve continued to do that because:
<<textarea "_should" "Type your answer here">>
<<button "Submit" "Next Passage Name">>
<<set $response = "Should: " + _should>>
<</button>>\
</span>
<span class="output">\
People shouldn't have done that because:
<<textarea "_not" "Type your answer here">>
<<button "Submit" "Next Passage Name">>
<<set $response = "Should not: " + _not>>
<</button>>\
</span>
The backslashes (\
) at the ends of lines there are just to prevent unnecessary line breaks, while keeping the code nice and readable as well.
Hope that helps! 