[SOLVED] Disabling viewport movement

Discuss how to use the Ren'Py engine to create visual novels and story-based games. New releases are announced in this section.
Forum rules
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
Post Reply
Message
Author
lignix
Newbie
Posts: 13
Joined: Mon Feb 28, 2022 1:00 pm
itch: lignix
Contact:

[SOLVED] Disabling viewport movement

#1 Post by lignix »

Hello !
I'm trying to disable (temporarily) the movement in a viewport when another menu is opened.
Here is a part of my code to explain more my problem:

Code: Select all

screen minigame():
	add DynamicDisplayable(viewport_listener, scr_name='minigame', widget_id='camera')
        viewport id 'camera':
            area (0, 0, 1280, 720)
            child_size (1600, 720)
            edgescroll (150, 1400)
            xinitial 0.5
            add "tv_bg"
            
        if viewport_state_variable == "right":
        	imagebutton:
        		idle "reparation_panel" action [ToggleScreen("panel_open"), SetVariable("in_menu",True), ###DISABLE MOVEMENT HERE###]
            
screen panel_open():
    add "panel_screen" at truecenter
    text "TABLET ON" at truecenter
    imagebutton:
        idle "reparation_close" action [ToggleScreen("panel_open"), ###DISABLE MOVEMENT HERE###)]
I tried doing something but I'm sure it's not the right way, and it doesnt word anyways. Here is what I've done:

Code: Select all

init python:
	def disable movement(screen, vp_id):
		renpy.get_widget(screen, vp_id).xadjustment.range = 0
And i set it back at its original value in another function. But it doesnt work perfectly. I have to move a little bit to have my imagebutton to show back again, and if i add renpy.restart_interaction(), I get an error.
Last edited by lignix on Wed Jul 12, 2023 4:58 pm, edited 1 time in total.

User avatar
Alex
Lemma-Class Veteran
Posts: 3098
Joined: Fri Dec 11, 2009 5:25 pm
Contact:

Re: Disabling viewport movement

#2 Post by Alex »

lignix wrote: Mon Jul 10, 2023 6:15 pm ...
Try to make the 'panel_open' screen to be the modal one - https://www.renpy.org/doc/html/screens. ... -statement

lignix
Newbie
Posts: 13
Joined: Mon Feb 28, 2022 1:00 pm
itch: lignix
Contact:

Re: Disabling viewport movement

#3 Post by lignix »

That was so simple thanks !

Post Reply

Who is online

Users browsing this forum: Google [Bot]