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

Marpel69

Member
Game Developer
Jun 16, 2023
150
336
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
Donor
Respected User
Jun 10, 2017
12,777
21,018
1,026
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.
 
  • Like
Reactions: Lexie lecoeur

Marpel69

Member
Game Developer
Jun 16, 2023
150
336
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!