• To improve security, we will soon start forcing password resets for any account that uses a weak password on the next login. If you have a weak password or a defunct email, please update it now to prevent future disruption.

Ren'Py How to store the the position of the scroll in the viewport?

Marpel69

Newbie
Game Developer
Jun 16, 2023
81
198
Hi! I'm making a messenger app in renpy, and I ran into a problem with viewport. It's always putting the player at the bottom of it, whenever you reenter it. I want to store how scrolled viewport is. I hope somebody knows how to do it properly.
 

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Respected User
Donor
Jun 10, 2017
10,233
14,994
Hi! I'm making a messenger app in renpy, and I ran into a problem with viewport. It's always putting the player at the bottom of it, whenever you reenter it. I want to store how scrolled viewport is. I hope somebody knows how to do it properly.
doc:
"yadjustment
The ui.adjustment() used for the y-axis of the viewport. When omitted, a new adjustment is created."

Therefore, you need to create your own object outside of the screen:
define myAdjust = ui.adjustment( [the values relevant for your case] )
Then use it in your viewport:
Code:
screen whatever():
    [...]
    viewport:
        yadjusment myAdjust
        [...]
And normally it should works like you want.
 

Marpel69

Newbie
Game Developer
Jun 16, 2023
81
198
doc:
"yadjustment
The ui.adjustment() used for the y-axis of the viewport. When omitted, a new adjustment is created."

Therefore, you need to create your own object outside of the screen:
define myAdjust = ui.adjustment( [the values relevant for your case] )
Then use it in your viewport:
Code:
screen whatever():
    [...]
    viewport:
        yadjusment myAdjust
        [...]
And normally it should works like you want.
Thanks!