Screens and Screen Buttons Problem

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
Broken
Newbie
Posts: 3
Joined: Thu Jan 04, 2018 2:53 pm
Contact:

Screens and Screen Buttons Problem

#1 Post by Broken »

Ok, I'm not new to Ren'py, but I'm VERY new to the screens functions. I want to basically have the button used to display the stats screen fade in after the tutorial guide says the line, "To visit the stats screen, click this button in the top right of the game window." I've looked through a couple tutorials to try to see how to do this, but I'm having issues displaying the screen button and screen at all. These are the codes I'm trying to use:

Code: Select all

## To define variables

init offset = -1
    
$ bob_points = 0
$ larry_points = 0
$ bob_max = 10
$ larry_max = 10
$ variable = False
And then the code to display the button itself (would love an image button but for now I'll take what I can get!)

Code: Select all

## Screen button##

textbutton "Stats"
action Show("stats_screen")

And for the information on the screen itself:

Code: Select all

## Stats Screen ################################################################
##
## Show player stats

screen stats_screen():
    frame: 
        has vbox 
        text "Bob: [bob_points] points" 
        text "Larry: [larry_points] points" 
        textbutton "Return" action Return() 
        
label aff_screen_label: 
    call screen aff_screen 
    return
So when I try to start my game, I'm getting the error:

File "game/screens.rpy", line 584: expected statement.
action Show->("stats_screen")

The -> is a red arrow.

Any help is greatly appreciated. Thanks in advance!

User avatar
Remix
Eileen-Class Veteran
Posts: 1628
Joined: Tue May 30, 2017 6:10 am
Completed: None... yet (as I'm still looking for an artist)
Projects: An un-named anime based trainer game
Contact:

Re: Screens and Screen Buttons Problem

#2 Post by Remix »

Code: Select all

textbutton "Click Me" action Show('stats')
# is the same as
textbutton "Click Me": # <--- note the : colon
    action Show('stats')
# Neither are the same as
textbutton "Click Me"
action Show('stats')
# which does not tell Ren'py that the action is part of the button
Frameworks & Scriptlets:

Broken
Newbie
Posts: 3
Joined: Thu Jan 04, 2018 2:53 pm
Contact:

Re: Screens and Screen Buttons Problem

#3 Post by Broken »

Thanks for the speedy response! I copied/modified the code you posted so that now line 583 is:

Code: Select all

textbutton "Click Me" action Show('stats_screen')
But now I'm getting the error:

File "game/screens.rpy", line 583: end of line expected.
textbutton "Click Me" ->action Show('stats_screen')

-> being another red arrow.

User avatar
Remix
Eileen-Class Veteran
Posts: 1628
Joined: Tue May 30, 2017 6:10 am
Completed: None... yet (as I'm still looking for an artist)
Projects: An un-named anime based trainer game
Contact:

Re: Screens and Screen Buttons Problem

#4 Post by Remix »

Without seeing how/where the textbutton appears in a screen it is hard to help further... How about showing us that part of the code too?
Frameworks & Scriptlets:

Broken
Newbie
Posts: 3
Joined: Thu Jan 04, 2018 2:53 pm
Contact:

Re: Screens and Screen Buttons Problem

#5 Post by Broken »

Sorry, like I said I'm pretty new to the screens thing and for some reason none of the tutorials I'm trying seem to be helping >.< I super appreciate you trying to help!

I want the text button to appear with a fade effect in the top right corner of the screen a few lines into the intro of the main story itself. It will lead to a 'stats' screen that shows the character's affiliation with the 2 characters listed. Is there a bit of code I need to put in the script.rpy file to make that happen? I've seen it done in the basic ren'py tutorial game, but without a button to call it (it just sort of happens) and I can't seem to find any code for it in the script/screen files when I open them up to edit them.

User avatar
Remix
Eileen-Class Veteran
Posts: 1628
Joined: Tue May 30, 2017 6:10 am
Completed: None... yet (as I'm still looking for an artist)
Projects: An un-named anime based trainer game
Contact:

Re: Screens and Screen Buttons Problem

#6 Post by Remix »

The best beginner Tutorial (with a huge amount of sample code) is in the Tutorial game/system that ships with Ren'py 6.99.13 or above.
If you are using an older version, I'd suggest updating and having a read/play through that (especially the Screens and Displayables sections)
Frameworks & Scriptlets:

Post Reply

Who is online

Users browsing this forum: Google [Bot]