Stats Screen/Bar Not Working?

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
That Oyajicon
Regular
Posts: 33
Joined: Sun May 29, 2016 7:31 pm
Location: The Pillars of Nosgoth
Contact:

Stats Screen/Bar Not Working?

#1 Post by That Oyajicon »

I'm following this tutorial video. I create an affection stats screen just as the instructions describe:

Code: Select all


#############################################################################
#Stats Menu
#A Screen For Your Stats and Stuff

screen button:
    vbox xalign 0.1 yalign 0.1:
        textbutton "Show Stats" action ui.callsinnewcontext("aff_screen_label")
        
screen aff_screen:
    frame:
        has vbox
    
        hbox:
            label "Jack:" xminimum 100
            bar range affection_max value bob_points xmaximum 500
        hbox:
            label "Joey:" xminimum 100
            bar range affection_max value joey_points xmaximum 500
        textbutton "Return" action Return()

label aff_screen_label:
    call screen aff_screen
    return
I go into the script.rpy and make a call to the screen as the tutorial describes:

Code: Select all

label start:

    # Show a background. This uses a placeholder by default, but you can
    # add a file (named either "bg room.png" or "bg room.jpg") to the
    # images directory to show it.

    scene bg room

    # This shows a character sprite. A placeholder is used, but you can
    # replace it by adding a file named "eileen happy.png" to the images
    # directory.

    show eileen happy

    # These display lines of dialogue.

    "Hello, world."
    $ affection_max = 100
    $ jack_points = 60
    $ joey_points = 20
    
    show screen button
    
    e "You've created a new Ren'Py game."

    e "Once you add a story, pictures, and music, you can release it to the world!"

    # This ends the game.

    return
When I launch the game, the "Show Stats" button appears in the top left of the screen (albeit without a cute little box), and when I click on it...I get a pretty big error.
I'm sorry, but an uncaught exception occurred.

While running game code:
File "game/screens.rpy", line 1416, in script
call screen aff_screen
File "renpy/common/000statements.rpy", line 471, in execute_call_screen
store._return = renpy.call_screen(name, *args, **kwargs)
File "game/screens.rpy", line 1403, in execute
screen aff_screen:
File "game/screens.rpy", line 1403, in execute
screen aff_screen:
File "game/screens.rpy", line 1404, in execute
frame:
File "game/screens.rpy", line 1405, in execute
has vbox
File "game/screens.rpy", line 1407, in execute
hbox:
File "game/screens.rpy", line 1409, in execute
bar range affection_max value bob_points xmaximum 500
File "game/screens.rpy", line 1409, in keywords
bar range affection_max value bob_points xmaximum 500
NameError: name 'bob_points' is not defined
I am very, very confused and I have no idea how to fix this. AFAIK, I followed the tutorial's instructions to the letter and everything just...broke.

User avatar
Ocelot
Lemma-Class Veteran
Posts: 2402
Joined: Tue Aug 23, 2016 10:35 am
Github: MiiNiPaa
Discord: MiiNiPaa#4384
Contact:

Re: Stats Screen/Bar Not Working?

#2 Post by Ocelot »

What is the value of bob_points when you show your screen and where is it set? See the problem now?

It is a good idea to define all variables beforehand:

Code: Select all

default bob_points = 0
default jack_points = 60
default joey_points = 20
< < insert Rick Cook quote here > >

User avatar
That Oyajicon
Regular
Posts: 33
Joined: Sun May 29, 2016 7:31 pm
Location: The Pillars of Nosgoth
Contact:

Re: Stats Screen/Bar Not Working?

#3 Post by That Oyajicon »

...That's what I get for simultaneously following a tutorial and also trying to be different by switching around the character names/pictures/etc. :oops:

Thanks for the help.

EDIT: I guess my next question would be, how do I go from these plain monochrome bars to something more like what you see in a typical otome game? Do I need to make a bunch of overlay elements, and then create a specialized screen?

Post Reply

Who is online

Users browsing this forum: Andredron, Google [Bot], Majestic-12 [Bot]