Creating a settings page

Twine Version: Harlowe 3.3.5

Hello, all.

I am trying to create a “Settings” page to allow players to change the text font and size for accessibility purposes, as well as general preferences. I think that I’ve got the code for the settings correct. My goal is that the variable $FontSize (by default set to 1) will be used to change all of the font to the corresponding size. However, I can’t test whether my code (see below) works, because once I click “Settings” I cannot leave that passage again. Even clicking return – which I don’t really want to do – doesn’t take me back to the passage I left. I think maybe it’s because I used (go-to:). Even so, I think (link-undo:) would just undo the change to the formatting.

If anyone has any solution, I would much appreciate it.

Code for Settings

The following puts a link to the “Settings” passage in the corner of the screen.

(float-box: "====X","Y====")[
(text-color: red+white)+(font: "Copperplate Gothic")[
[[Settings->Settings]]]
]

The “Settings” passage looks like this:

(align:"=><=")+(text-size:2.0)+(text-color: red+white)+(font: "Copperplate Gothic")[''Settings'']

''//Change Font Size://'' [[(-)->decrease font]] [[(reset)->default font size]] [[(+)->increase font]] 

The passages that are linked look like as follows:

{
(set: $FontSize to $FontSize+0.2)
(go-to: "Settings")
}

I also have the following line of code that should run for every passage:

(enchant: ?text, (size: $FontSize))

Untested, but I think you could tag Settings and “decrease font” etc. with a “settings” tag and then get the most recent non-settings passage with (history: where its tags does not contain "settings")'s last … so then maybe:

(link-goto: "Return to game", (history: where its tags does not contain "settings")'s last))
1 Like

It didn’t quite work, but I tagged the story passages with “main-game” and adjusted the code to

(link-goto: "Return to game", (history: where its tags contains "main-game")'s last))``

After much tinkering, I think I have at least text size figured out. Now it’s on to font.

Thanks so much! I don’t think I would have figured out how to use (history:) without your help!

EDIT: Actually, that would work perfectly… if I just tagged the other passages I used for the font size. I’m a chronic over-complicator and did not realize the very simple solution you handed me until I tagged half of my story passages.

1 Like