Trouble with Screen Language On Show [SOLVED]

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
trooper6
Lemma-Class Veteran
Posts: 3712
Joined: Sat Jul 09, 2011 10:33 pm
Projects: A Close Shave
Location: Medford, MA
Contact:

Trouble with Screen Language On Show [SOLVED]

#1 Post by trooper6 »

Greetings!

I've created a function that will dump playtest data into a file.

Code: Select all

init -1 python:
    
    def generate_feedback_file():
        feedback = open ("feedback.txt", "w+")
        feedback.write(persistent.f1);
        feedback.close()
So that is good. Now in the Main Menu, I've added a text button:

Code: Select all

textbutton _("Generate Playtest Data") action ShowMenu("playtest_info")
Here is the ShowMenu I created:

Code: Select all

screen playtest_info():
    on "show" action Function(generate_feedback_file)[

    tag menu 
    use navigation
    
    vbox:
        spacing 25
        ymaximum 500
        yalign .5
        xalign .5
        
        add "play_title":
            xalign .5
            yalign .5
/code]

The trouble? Doing this doesn't cause the function to run. Why not?

Instead I took out the "on show" line of the screen and changed my button to this:
[code]textbutton _("Generate Playtest Data") action [Function(generate_feedback_file), ShowMenu("playtest_info")]
This works no problem. But shouldn't the on command work?
Last edited by trooper6 on Thu Jan 29, 2015 11:25 am, edited 1 time in total.
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

User avatar
shivanshs9
Regular
Posts: 54
Joined: Sun Jul 20, 2014 1:59 pm
Projects: The Destiny(http://thedestiny-cxz.blogspot.com)
Organization: Cyber-X-Zone
Location: India
Contact:

Re: Trouble with Screen Language On Show

#2 Post by shivanshs9 »

I can't say for sure, but maybe use on "replace" too, since your screen replaces all the menu screens...
Your code:

Code: Select all

    on "show" action Function(generate_feedback_file)[
Also, what is that [ in the end? It could be the source of problem...
New code:

Code: Select all

    on "show" action Function(generate_feedback_file)
    on "replace" action Function(generate_feedback_file)
"Destiny is a no matter of chance
It is a matter of choice
It is not a thing to be waited for
It is a thing to be achieved..."

-William Jennings Bryan
If you can dream and not make dreams your master;
If you can think and not make thoughts your aim,
If you can meet with Triumph and Disaster;
And treat those two impostors just the same,
Only then can you ever win against yourself...

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: Trouble with Screen Language On Show

#3 Post by trooper6 »

on "replace" worked perfectly! Thanks so much!
(the bracket was an artifact of copy/paste)

So...on "show" only works when the screen pops up without replacing...
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: Google [Bot]