Pause UDD from screen?

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
User avatar
Mole-chan
Veteran
Posts: 333
Joined: Thu Aug 27, 2009 12:46 am
Completed: DUAEL, Escape from Puzzlegate
Projects: A Bird with Gold-Mended Wings
Deviantart: mole-chan
Skype: mole-chan
itch: moleworks
Contact:

Pause UDD from screen?

#1 Post by Mole-chan »

Hello,
I am creating a UDD framework with some time sensitive interactions, and notice that they still run in the background even while the user is trying to quit. I figured out how to pause this interaction when the displayable is in focus, but once another screen is shown, it just keeps going regardless.

Obviously, this would not be fair to the user, so I was wondering if there is possibly a way to forcefully pause a displayable while another screen is in focus?

Thank you.

User avatar
nature1996
Regular
Posts: 62
Joined: Wed Jun 21, 2017 10:35 am
Contact:

Re: Pause UDD from screen?

#2 Post by nature1996 »

I'm not sure if it will work, but maybe defining your screen as modal might solve the problem: https://www.renpy.org/doc/html/screens. ... -statement

If it is about timer in the background, or running function, you might have to manually pause it when a menu is open. I'm pretty sure there is a flag that is raised when a screen considered as a menu is show, but I don't know its name or how to raise it if you are using a personal screen.

In order to help more, we would probably need the problematic part of your code (or a facsimile with placeholder) in order to see and test for ourselves.
Je parle aussi français

User avatar
SONTSE
Regular
Posts: 96
Joined: Sun Nov 24, 2013 10:49 pm
Completed: 11 VN's so far
Discord: jkx0282_10798
Contact:

Re: Pause UDD from screen?

#3 Post by SONTSE »

Just made my example for UDD which pauses when enters game menu (right click). Not pretty, but you can utilize it if nothing better comes along.
Hope it helps :wink:

Code: Select all

init python:
    config.layers.append('X')
    
    def any(list):
        for item in list:
            if item:
                return True
        return False
    
    class Paused(renpy.Displayable):
        def __init__(self,child,screen):
            super(Paused,self).__init__()
            self.child = renpy.displayable(child)
            self.screen = screen
            self.xt = 0
            self.ct = 0
            
        def render(self, width, height, st, at):
            child_render = renpy.render(self.child, width, height, st, at)
            self.width, self.height = child_render.get_size()
            render = renpy.Render(self.width, self.height)
            render_y = self.xt*100 % 620
            render.blit(child_render, (0, render_y))
            return render
        
        def event(self, ev, x, y, st):
            if not any([renpy.get_screen(scr) for scr in self.screen]):
                self.xt-=self.ct-st
            renpy.redraw(self,0)
            renpy.timeout(.0)
            self.ct = st
            return self.child.event(ev, x, y, st)
    
image sol = Solid('#f0f',xysize=(100,100))
image paused = Paused('sol',['save','load','history','preferences'])

label main_menu:
    return

label start:
    show paused at topleft onlayer X
    while True:
        'foo'
        'bar'
    return

Post Reply

Who is online

Users browsing this forum: No registered users