0 votes
asked by (160 points)

Hi everyone,

I've prepared a simple educational story. The user is given some form of feedback throughout the story, but I also like to recap at the end. Therefore, whenever the user takes a wrong step, I set it in a related variable for the end.

In the end of the story, the player sees a coach, and asks for feedback. At this point, I have 12 passages, each belonging to one of the possible faults, like this:

(if: $nohelp is 1)[

The advice goes here...

[[End of feedback<-Thanks for the feedback. I have to go now.]]
[[feedback07<-I see. What else?]]

](else:)[

(live: 0s)[(goto: "feedback07")]

]

In other words, if that specific feedback is not needed, it immediately goes to the next one.

Can anyone suggest a better way of doing this?

What I'm doing now looks a little complicated, and also, if it's needed to ignore multiple feedbacks in a row, there will be multiple page loads.

 

Thanks for the help.

1 Answer

+1 vote
answered by (115k points)
selected by
 
Best answer

> Can anyone suggest a better way of doing this? ... , there will be multiple page loads...

If I understand correctly you are looking for a way to implement your feedback advice section that doesn't include Passage Transitions between each piece of advice given and that removes the need for the (live:) macro.

The follow uses an Array ($helpNeeded) to track which pieces of advice (the "advice X" String values) the Reader needs to see, it then uses that Array to conditionally show that advice. The relavent "advice X" String value is removed from the Array when the Reader has see the related advice and if the no advice was needed (the Array was empty) then the Reader is automatically forward to the "End of feedback" passage. The "I see. What else?" link is only shown if there is more advice to be shown.

1. Initialise the Array within your project's startup tagged special passage.

If you don't have one yet then simply add a new Passage to your project (the name you give this passage isn't important, I name mine Startup) and assign this new Passage a tag of startup (all lowercase)

(set: $helpNeeded to (a:))


2. Update the Array each time it is determined that the Reader needs advice.

You can use whatever values makes sense to you, this example uses "advice 1", "advice 2", ..., "advice 12".

eg. when it's determined that the Reader will need Advice 1 then do the following.

(set: $helpNeeded to it + (a: "advice 1"))

... when it's determined that the Reader will need Advice 2 then do

(set: $helpNeeded to it + (a: "advice 2"))

.. and so forth.

3. In the Passage you want to see the IN do the following.

|advice>[(display: "Feedback Advice")]


4. Add a Feedback Advice Passage to your project.

This is where all the real work is done, it checks the contents of the Array and shows each required piece of advice in turn, it also displays the relevent links as needed. For brevity sake I have only implemented the logic code required for advices 1 to 3, but I think you'll be able to understand how to do the rest.

{
	(if: $helpNeeded's length is 0)[
		(go-to: "End of feedback")
	]
	(elseif: $helpNeeded contains "advice 1")[
		(set: $helpNeeded to it - (a: "advice 1"))\

		The advice for feedback 1.
	]
	(elseif: $helpNeeded contains "advice 2")[
		(set: $helpNeeded to it - (a: "advice 2"))\

		The advice for feedback 2.
	]
	(elseif: $helpNeeded contains "advice 3")[
		(set: $helpNeeded to it - (a: "advice 3"))\

		The advice for feedback 3.
	]
}

(link-goto: "Thanks for the feedback. I have to go now.", "End of feedback")
(if: $helpNeeded's length > 0)[\
	(link: "I see. What else?")[
		(replace: ?advice)[(display: "Feedback Advice")]
	]\
]

 

commented by (160 points)
Thanks @greyelf, it's brilliant.

I just changed my story and applied this approach; it's now much more organized and easier to maintain.
Welcome to Twine Q&A, where you can ask questions and receive answers from other members of the community.

You can also find hints and information on Twine on the official wiki and the old forums archive.

See a spam question? Flag it instead of downvoting. A question flagged enough times will automatically be hidden while moderators review it.
...