0 votes
by (790 points)

What I have is something like:

<<linkreplace "blah blah">><<include "New Passage 2">><</linkreplace>><</append>>

To have links that reveal paragraphs that contain other links (which in turn reveal more of such paragraphs). This works fine, but as I have many paragraphs on one page, I want the page to scroll down automatically after the player clicks on a link, so he/she doesn't have to scroll down manually every time. This is a good example of what I'm looking for. Can this be done?

1 Answer

+1 vote
by (159k points)
selected by
Best answer

1. SugarCube waits until a Passage Transition (moving for one Passage to another) has occurred before it updates the History system with the current state (values) of the known Story Variables, this means any changes done to the story variables during the displaying of the current Passage aren't tracked by the History system and haven't happen as far as it's concerned. So if the page is refreshed then all the story variables changesmade while viewing the current Passage will be undo, and the same goes for any outcomes caused by the Reader selecting links that didn't result in a Passage Transition.
This is one reason why the 'end-less' page effect you're trying to implement isn't recommend if: it changes the values of story variables; or you want the selection of (non-transition) links to be remembered.

2. People can have different sized screens or web-broswer view-port than you, so if the new block of text being added is long then automatically scrolling downwards may cause the start of that new block of text to scroll off the top their screen.

The answer to the <<timed macro>> Autoscroll Twine 2 Sugarcube question includes an example of a custom <<scrolldown>> macro you can add to your project's Story Javascript area, this would allow you to achieve the effect you are looking for.

Block of text...

<<linkreplace "blah blah">>
	<<include "New Passage 2">>


by (790 points)
Thanks so much! I'm fine with concern #2, but just to confirm, I shouldn't set any variables on the passage that I use <<scrolldown>> on, right?
by (159k points)
> I shouldn't set any variables

You can <<set>> them and even use their current values, they just won't be persisted to the History system until the next Passage Transition occurs so their values will be reset if the web-page gets refreshed.
by (790 points)
Got it. Thanks again!