weird question — trying to physically print the last story passage in my game

+1 vote
asked Nov 11 by awesomnia (130 points)

Hey all — I haven't been able to find any info about anyone else trying to do this, and I have no idea how to do it myself. I'm trying to set up a thing so the player can click a link and physically print the last story passage — like, to an actual printer. Does anyone have any experience doing this? 

My thoughts right now are that I'd have to set it so that it calls up a javascript function when the link is clicked, but other than that, I'm pretty lost. 

Thank you! literally any help would be very appreciated. 

1 Answer

0 votes
answered 6 days ago by Chapel (30,050 points)

You can use window.print(), which will open the browser's print UI for the user.

Try something like this:

Blah blah blah.

(link-repeat: 'Print this page!')[\
    (set: _dummy to print())\
]

Or this:

Blah blah blah.

(link-repeat: 'Print this page!')[\
    <script>print();</script>\
]

This may not work in <iframes> or embedded content, such as on itch.io.

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