0 votes
by (120 points)
I want to have a sequence of events display based on the turn number. I know to use IF/THEN/ELSE but I want to know how to handle the turn counter so at turn 3 something is displayed, turn 5 something else, and so on until the player makes a choice which stops the action.

Example: Turn 3 an NPC shows up, Turn 5 the NPC wants to fight, Turn 7 the fight begins. But the sequence can be stopped if the player makes a choice to leave the room.

Thanks

1 Answer

+1 vote
by (158k points)

There are a number of ways you could implement this depending on what exactly a 'turn' means in your story.

1. Does a 'turn' pass each time the Player selects a particular link related to the current Location/Room?

eg. Does the room have a Wait (like) link that increments the numeric value of your $tuns variable.

<<link "Wait">>
	<<set $turns += 1>>
<</link>>

... if so then you could place the <<if>> related macros within the body of that <<link>>.

2. Does a 'turn' pass each time any links related to the current Location/Room are selected?

<<link "Room Option 1">>
	... do something ...
<</link>>

<<link "Room Option 2">>
	... do something else ...
<</link>>

... in this case you may want to create a custom widget to store the <<if>> related macros in and then call that custom widget within each of the bodies of the Room related links.

3. Does selecting any links in the story's interface increment the number of $turns?

... if so then you might be able to use the Config.navigation.override setting to intercept the selecting of any link and call the custom widget from point 2 from there instead.

4. Does the passing of real-world time increment the number of $turns?

... if so then you will need to attach a timer handler to monitor the passing of time and then call point 2's custom widget from it instead.

5. Some other meaning of 'turn' or some other way of incremental the number of $turns....

 

by (120 points)
That's awesome. I'm going to play around with it. I just wanted to know if it was possible before I even started.

Thanks
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.
...