+1 vote
by (820 points)

Something came up during a bugtesting run with a couple of my guinea pigs... i mean victims... er... test subjects recently. While most of the time, I try to give players enough information to give them a solid amount of immersion while still leaving lots of room for their imagination to build the visuals, I do have a few event scenes that are a bit longer. A few of these run on long enough to be off screen, and in the case of one of my minions who has an OLD monitor, even regular room descriptive can run off screen if they're longer, or there are more objects in the room.

Most of the time this isn't a problem. This is a game for people who like to read.

The problem comes in when I use a <<replace>> to change the text on screen instead of going to a new passage; and I'm using this rather a lot in the new layout framework I've built. If the text is long and the player has to scroll, the scroll bar Remains at the Bottom of the screen after the change, so that the player has to scroll back up before reading.

It's not game-breaking, but it is the kind of nagging, large-scale annoyance that I'm trying to avoid (and that led to me creating a frame layout for controls and navigation in the first place).

Is there a way to make the window scroll back to the top of a passage?

(fair warning: I'm learning, but mostly through usage, so my grasp of programming is still questionable. I may not always catch some of the technical jargon. I'm only JUST starting to get the idea behind arrays, for crying out loud!)

1 Answer

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

You can use the window.scroll() function: 

<<run scroll(0, 0)>> /% top of the page %/

It should work, but I'm not sure about the kind of layout you're using. 

by (820 points)

Works perfectly!

I did not know about that function, but that actually solves the entire issue. Thanks, Chapel! =^^=

 

And the layout is the normal page with larger margins to accommodate several area frames that hold character status, inventory access and updates, a navigation map, and a panel specifically for currently available actions the character can take.

Basically, every Passage has its own basic text contained in a span that can be replaced by text from various actions. After each Passages text area, is some hidden code so that each time the passage loads, it changes the available map data, actions menu, and occasionally hijacks the character status panel with REALLY important updates... "There is a soft ticking... lick a dogs claws on a tile floor..."

Actually, the whole new layout I'm using is thanks to you, too, as you're the one who pointed out that it was trying to update the frames before they were rendered onto the page. A 1ms delay on the frame code solved that whole mess. =^^=

...