Function() Screen Action + renpy.show_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
ChesStrategy
Regular
Posts: 96
Joined: Wed Jan 14, 2015 7:01 pm
Contact:

Function() Screen Action + renpy.show_screen()

#1 Post by ChesStrategy »

Hi all,

I have an imageButton with the Function() screen action; set to call the callable below.

Code: Select all

def run_tmg():
            global some_data
            global counter
            counter += 1
            renpy.log( "I was here" )
            renpy.show_screen( "the_mini_game", some_data, _layer='master' )
I supply config.log with a text file name, and I can see that when I click on the imagebutton, "I was here" is printed out. However, counter is not updated, and no screen is shown. Is there an issue with globals? The code did not throw or error at all.

Regards,
ChesStrategy

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

Re: Function() Screen Action + renpy.show_screen()

#2 Post by xela »

Did you try restarting interaction? Chances are that everything is working just fine.
Like what we're doing? Support us at:
Image

User avatar
trooper6
Lemma-Class Veteran
Posts: 3712
Joined: Sat Jul 09, 2011 10:33 pm
Projects: A Close Shave
Location: Medford, MA
Contact:

Re: Function() Screen Action + renpy.show_screen()

#3 Post by trooper6 »

Xela is right.

This code works for me:

Code: Select all

screen counter_screen():
    text "[counter]" xalign 0.5 yalign 0.5
    
screen control_screen():
    textbutton "Counter" action Function(run_tmg)
    
init python:
    def run_tmg():
        global counter
        counter += 1
        renpy.show_screen("counter_screen")
        renpy.restart_interaction()
    
# The game starts here.
label start:
    $counter = 0
    show screen control_screen()
    
    "Press the counter button"
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?)
Check out My Clock Cookbook Recipe: http://lemmasoft.renai.us/forums/viewto ... 51&t=21978

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

Re: Function() Screen Action + renpy.show_screen()

#4 Post by ChesStrategy »

Yea, sorry, it does work; I just happen to not click one more time afterward to see the screen appear. I just assumed it would appear as soon as I clicked the button.

Is there a way to end the current interaction immediately then move on to the next one?

Is there also a way to do what shift-O (the dev console) does; where it displays a screen without allowing the current interaction to proceed to the next one.

One last question, if it is ok; is there also a way we can see through some developer tool; what interaction/line we are currently on in the code?

Thanks,
ChesStrategy

User avatar
trooper6
Lemma-Class Veteran
Posts: 3712
Joined: Sat Jul 09, 2011 10:33 pm
Projects: A Close Shave
Location: Medford, MA
Contact:

Re: Function() Screen Action + renpy.show_screen()

#5 Post by trooper6 »

ChesStrategy wrote:Yea, sorry, it does work; I just happen to not click one more time afterward to see the screen appear. I just assumed it would appear as soon as I clicked the button.
If you put renpy.restart_interaction() at the end of your function like I did in the code I provided for you, the screen will show up as soon as you click the button.
ChesStrategy wrote: 1) Is there a way to end the current interaction immediately then move on to the next one?

2) Is there also a way to do what shift-O (the dev console) does; where it displays a screen without allowing the current interaction to proceed to the next one.

3) One last question, if it is ok; is there also a way we can see through some developer tool; what interaction/line we are currently on in the code?

Thanks,
ChesStrategy
I don't know if I can answer your questions, but partly that is because I don't quite understand them--which might be me. But could you give a specific and detailed explaination of what exactly you want to happen? What kinds of interactions are you talking about? What is reason the interaction is ended immediately and proceeded to the next one? When you say you want a screen to pop up without allowing the current interaction to proceed to the next one...do you mean like a menu screen or yes/no screen?

Can you give an explaination in real game terms of what you are wanting?

As for question 3, I don't know, I usually just follow along the game while looking at my Renpy files so ?I always know where I am.
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?)
Check out My Clock Cookbook Recipe: http://lemmasoft.renai.us/forums/viewto ... 51&t=21978

Post Reply

Who is online

Users browsing this forum: No registered users