Stop scrolling

Rach227
12 Feb 2022, 14:09

Hi All,

I'm wanting to stop the game from scrolling to the bottom, as one or two of my pages are little long. I'd rather not split them so there is no random split between dialogue.

I have seen there is javascript code that can be used to stop this. My question is, where do I enter it? I have tried copy and pasting the info from this article:

http://textadventures.co.uk/forum/quest/topic/yg5cx4tgfu2onjrcc6a4ow/page-immediately-scrolls-to-bottom

into various places but it's still doing it. Any help would be appreciated.

Thanks,

Rachel


Rach227
12 Feb 2022, 16:05

Never mind, please close. I managed to find it :)


Deckrect
20 Feb 2022, 10:51

I used the same code from the other topic, but I faced a problem. How to make the game scroll again, at least for a few commands and pages?


mrangel
20 Feb 2022, 13:03

I used the same code from the other topic, but I faced a problem. How to make the game scroll again, at least for a few commands and pages?

I think you could use JS.eval("addTextAndScroll = addText;") to disable automatic scrolling when output is printed; and then manually call JS.scrollToEnd() when you want it to scroll. Or JS.eval("AddTextAndScroll = function(text) {addText(text); scrollToEnd();};") to restore the default automatic scrolling.

If you have parts where scrolling is enabled or disabled, remember that this won't be restored when a saved game is loaded. You would need to check in the UI Initialisation script whether autoscrolling should be turned on at the moment, and disable it otherwise.


Deckrect
20 Feb 2022, 14:43

Nothing is happening. I tried a few combinations.

Let me explain: I have a page with an image on top and the text. The floating frame wasn't good enough for me, because the room for the text was too little. So I decided let it scroll by user intervention. To do so, I had to remove the auto scrolling as a game start script.

However, when the player uses the "Look at", the description gets sunk down in the page and out of sight, so, I guess the better is forcing a scroll down only on pages with long descriptions, where it may happen.

I used the Run Script for the Look At like this:

msg ("Flip to next page.")
JS.scrollToEnd ()


mrangel
20 Feb 2022, 18:46

Was that using the modified addTextAndScroll instead of disabling scrollToEnd?


Deckrect
21 Feb 2022, 09:33

What I'm currently using is JS.eval ("scrollToEnd = function () {};") as a Start Script

Then, inside the "Look at" option I'm running:

msg ("Flip to next page.")
JS.scrollToEnd ()


Deckrect
21 Feb 2022, 09:41

Now I put JS.scrollToEnd() in Game, "when entering a room".

In the "look at" I put :
JS.JS.eval ("AddTextAndScroll = function(text) {addText(text); scrollToEnd();};")
msg ("Flip to next page.")


mrangel
21 Feb 2022, 11:06

I did say that you could try putting JS.eval("addTextAndScroll = addText;") instead of JS.eval ("scrollToEnd = function () {};").

  • JS.eval("addTextAndScroll = addText;") stops JS.scrollToEnd() being automatically run after every msg.
  • JS.eval ("AddTextAndScroll = function(text) {addText(text); scrollToEnd();};") starts JS.scrollToEnd() being automatically run after every msg again (the default behaviour).
  • JS.eval ("scrollToEnd = function () {};") makes the function scrollToEnd do nothing – so the previous 2 will have no effect.

Also,

What I'm currently using is JS.eval ("scrollToEnd = function () {};") as a Start Script

I hope you mean UI Initialisation script. If you put it in the start script, it will revert to default behaviour when loading a saved game.


Deckrect
21 Feb 2022, 11:28

Hmmm... It's not working. I will do this: I'm finishing a sort of DEMO version to publish and seek if anyone is interested to act as my editor.

Can you a look into the real thing? It will save you from wasting work.

But thank you anyway!


SamuelBacker
19 Apr 2022, 18:33

Hello all here