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.
Also...what are you ultimately trying to do? why do you want your image to regularly call a screen each second it is rendered? You are nesting so many screens in there? There has got to be an much easier way to do whatever it is you want to do. I'd say probably with just screen language.
So...what are you ultimately trying to do? Do you really need a CustomDisplayable at all?
A Close Shave:
*Last Thing Done (Aug 17): Finished coding emotions and camera for 4/10 main labels.
*Currently Doing: Coding of emotions and camera for the labels--On 5/10
*First Next thing to do: Code in all CG and special animation stuff
*Next Next thing to do: Set up film animation
*Other Thing to Do: Do SFX and Score (maybe think about eye blinks?)
I'm trying to code up a mini-game, and the user interaction is complex enough that I don't think using screen language will suffice (I've tried). I get the feeling that using custom displayables is discouraged, but it is very powerful and flexible depending on how you use it. And it aligns well for my use-case so far.
I have conditions that trigger the renpy.show_screen() in my code, so it won't render one after another constantly. But the point of the code sample above was to show that calling show_screen() is not working. As you said, it should be calling it over and over because it's in the render(), yet if you run the code it doesn't show up.
And you're right... "print" isn't a screen action, but I have it there so I can see it show up in the console when the screen is shown, which it never is and so that print statement never runs.
Is this expected behavior, that calling show_screen() will not show the screen? If not, then is this considered a bug, or am I missing something?
Displayables are quite powerful and very cool. I made an entire tutorial on them. But I have never seen an example of a displayable that included screen language. I don't know how wise that is. I see screens holding Displayables, but I don't see Displayables calling screens in their renders. Even the Pong mini game example in the tutorial doesn't involve that Displayable calling screens.
But if you are getting you game to work the way you want, keep going!
A Close Shave:
*Last Thing Done (Aug 17): Finished coding emotions and camera for 4/10 main labels.
*Currently Doing: Coding of emotions and camera for the labels--On 5/10
*First Next thing to do: Code in all CG and special animation stuff
*Next Next thing to do: Set up film animation
*Other Thing to Do: Do SFX and Score (maybe think about eye blinks?)
Theoretically it should work (even though I agree with trooper6 on it not being a wise approach) with a few areas that might be causing problems:
The displayable must be refreshing correctly, perhaps a print("render called") in the render method as a quick test to see if it runs lots of times per second.
Presuming the conditionals work, after the show_screen call it doesn't look like you are telling Ren'Py to redraw everything, perhaps a restart_interaction, full_redraw or redraw(get_screen('...'))
Simplest debug route is just scamper the render conditional logic and add "print('done NNN')" at various points... basically let the code say where it is rather than just waiting for a screen to show... If the console says the show_screen call was done and no screen showed, you know where the snaffu is
Personally, I'd put the logic in a screen, maybe add it to config.per_frame_screens if needed then have any interactable elements (displayables) just alter variable values to let the screen logic decide what to display (including on-off child screens)
renpy.restart_interaction() worked... Although with everyone saying how weird it is to use show_screen() inside a CDD, I think I might be not understanding cdd correctly. Thanks guys! Might have to rewrite all my code...
When is it appropriate to use renpy.show_screen(), or any of the renpy.X functions? Because CDD is coded in python, and those functions are also in the section where python and renpy intersects.