Quick question regarding renpy.redraw( self, 0 )

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
ChesStrategy
Regular
Posts: 96
Joined: Wed Jan 14, 2015 7:01 pm
Contact:

Quick question regarding renpy.redraw( self, 0 )

#1 Post by ChesStrategy »

Hi renpy users, a quick question for anyone whose used UDDs/CDDs:

If you call renpy.redraw( self, 0 ) in the render() function of a UDD. If that UDD is deep inside a large tree of parent child displayables, does all of the parent/ancestor displayables also redraw? Here is an example:

Code: Select all

#Inside UDD A:
def render( ... ):
    ...
    renpy.redraw( self, 0 )
    return some_render

Fixed A has another Fixed B as a child; Fixed B has multiple children including UDD A...

Fixed A's other children:
Displayable C

Fixed B's other children:
Displayable D

Now... questions:
1. Is Fixed A, Fixed B, UDD A all re-rendered constantly due to UDD A?
2. Are Displayable C and D also re-rendered? (i.e. their render function is called; instead of using a cached result?)

EDIT: one last question (slightly unrelated)
3. Are all displayables shown in all layers redrawn once per interaction? Sorry if I've forgotten some details.

Thanks,
Ches

User avatar
xela
Lemma-Class Veteran
Posts: 2481
Joined: Sun Sep 18, 2011 10:13 am
Contact:

Re: Quick question regarding renpy.redraw( self, 0 )

#2 Post by xela »

ChesStrategy wrote:Now... questions:
1. Is Fixed A, Fixed B, UDD A all re-rendered constantly due to UDD A?
2. Are Displayable C and D also re-rendered? (i.e. their render function is called; instead of using a cached result?)
Whatever is rendered inside of a displayable that you ask to redraw is "re"rendered when you request a redraw, this seems like a very plain and direct explanation and the only way
it could (should) work.
ChesStrategy wrote:Now... questions:
3. Are all displayables shown in all layers redrawn once per interaction? Sorry if I've forgotten some details.
Most likely... this is something you need to test. I am fairly sure that they are all being rendered but they may not all get their states updated. One of the major improvements in SL2 if I recall correctly, were displayable that were not being updated if their states remained unchanged, they would just be shown again with whatever was in the memory at that point. At least it's the way I understood it, maybe there are other things at play or I misunderstood it completely.

Usually when I get those questions, I try to dig in code or try it out myself.
Like what we're doing? Support us at:
Image

ChesStrategy
Regular
Posts: 96
Joined: Wed Jan 14, 2015 7:01 pm
Contact:

Re: Quick question regarding renpy.redraw( self, 0 )

#3 Post by ChesStrategy »

Xela,

There might be some misunderstanding; I know UDD A will be re-drawn; but since UDD A will be and it is a child of a parent displayable; does UDD A's parent also get redrawn as a result of the redraw() call in UDD A?

User avatar
xela
Lemma-Class Veteran
Posts: 2481
Joined: Sun Sep 18, 2011 10:13 am
Contact:

Re: Quick question regarding renpy.redraw( self, 0 )

#4 Post by xela »

ChesStrategy wrote:There might be some misunderstanding; I know UDD A will be re-drawn; but since UDD A will be and it is a child of a parent displayable; does UDD A's parent also get redrawn as a result of the redraw() call in UDD A?

Code: Select all

class Parent(renpy.Displayable):
    # I am a parent!

class A(Parent):
    # I am a child!
    #... bla bla bla
    def render()
        r = renpy.Render(w, h)
        r.blit(#10000000 renpy.renders at some positions.)
        return r
        # Now Child A does swear solemnly not to call a render method of it's Parent unless something along the lines of super(A, self).render() is called...
I am not 101% sure but so far in 100% of the cases, I could count on Ren'Py internal code to behave as it is generally expected in Python... I am not sure why/what you expect to go differently here? (So no, Children do not redraw Parents... I cannot imagine why you'd think that they do).
Like what we're doing? Support us at:
Image

Post Reply

Who is online

Users browsing this forum: Ocelot