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

Marpel69

Newbie
Game Developer
Jun 16, 2023
65
172
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,124
14,803
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
65
172
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!