0 votes
by (370 points)
edited by

Hey there,

I posted previously about my efforts to create a loop that would summarize the story players had created here. Greyelf provided a great solution that did exactly what I asked for. Having now, tried to fully implement it in my game, I find I was asking for the wrong thing. :)

What I'm trying to create is basically a script generator. A player goes through the prose, making decisions like in a typical CYOA, but in the end they are given a script, like for a play, which retells the story in the way they selected. 

For example, as the player goes through they would see:

"Hello," said the man.

But the script would print out:

MAN: Hello.

Hence, I've built two fairly different versions of the text.

Two challenges I need help solving:

1) The if/else logic I'm using to parse through the entire game is much too resource intensive. My (relatively fast) computer spends a long time generating the script page. I'm wondering if anyone has an alternative suggestion. Would it be faster to fill an array over the course of the game and then spit out it's contents at the end? Is there a better approach to this?

2) Is there any way to produce a PDF or some sort of standard printable document with Twine? If not, are there any suggestions for how to format that will make printing simpler for a user?

1 Answer

0 votes
by (340 points)
edited by

First of all this is a really cool idea! I have a suggestion to simplify your approach: 

If I were you I would skip for loops, I really hate using them in Twine unless I have to. If you have several key narrative branches, I would simply use the (contains:) function on (history:) to check what the player did, instead of looping through the whole thing passage by passage: 

(if:(history:) contains "SwamLake")[You swam across the lake.]

When you have cases where the order of passages matter, just do an index check (using JavaScript's "indexOf()" function): 

(if:(history:).indexOf('SwamLake') < (history:).indexOf('TakeSword'))[You swam across the lake before taking the sword.] 

Naturally you'd want to nest this inside a check that both of these appear in the history. 

...