Screens to track date/time not showing [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
ninjew_42
Newbie
Posts: 4
Joined: Fri Jul 13, 2018 10:01 pm
Tumblr: glompme
Contact:

Screens to track date/time not showing [solved]

#1 Post by ninjew_42 »

Ren'Py version 7.0.0.196

I have a switch in a game I'm trying to make which turns on and off a screen for the date/time and another for the amount of money the player has to display in the top left and top right corners respectively. The code however does not appear to be working as nothing happens when I run the game and get to the point the game switches the date/time switch on and the player cash switch to on.

Instead I just see the background, the character in front, and the text box.

When I run the game the switches are switched from off to on and I have tested with them just starting in the on position but that did not resolve either.
Starting code is and the screen button code below are both under the screens.rpy file.

Code: Select all

    $ day_button_switch = False
    $ credit_button_switch = False
changing to:

Code: Select all

label normal_day:
    $ day_button_switch = True
    $ credit_button_switch = True
    n "This is a normal day."
I have this same code in another game I started making with an older version of Ren'Py and I'm not getting the issue on this version of Ren'Py on that game. So the code is fine. Granted I did make the date code...more complicated than the other game.

Code: Select all

screen button:
    if day_button_switch:    
        vbox xalign 0.0 yalign 0.0:
            frame:
                vbox:
                    text "[month] [current_day], [current_year], [current_weekday]"
                    text "[hour]:[minute] [ampm] - [current_time]"
    if credit_button_switch:    
        vbox xalign 1.0 yalign 0.0:
            frame:
                has vbox
                text "$ [player_cash]"

My full screens.rpy init code pertaining to these two items and some additional stuff.

Code: Select all

init:
    $ day_button_switch = False
    $ credit_button_switch = False
    $ month = "August"
    $ current_year = 2022
    $ current_date = 1
    $ current_weekday = "Monday"
    $ season = 1
    $ hero_history = 0
    $ leap_year = False
    $ hour = 6
    $ minute = 00
    $ ampm = "am"
    $ current_time = "Early Morning"
    $ player_cash = 0
Last edited by ninjew_42 on Fri Jul 13, 2018 11:11 pm, edited 1 time in total.
Most people in my experience wouldn't know reason if it walked up and shook their hand. You can count Gul Dukat among them.

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: Screens to track date/time not showing

#2 Post by trooper6 »

It is current best practice to initialize your variables not in an init, but using default.
Also, you may want to have your screen hold a Fixed that then holds the vboxes.
And lastly, make sure you show the screen when the game starts.

So something more like this, which works:

Code: Select all

default day_button_switch = False
default credit_button_switch = False
default month = "August"
default current_year = 2022
default current_date = 1
default current_weekday = "Monday"
default season = 1
default hero_history = 0
default leap_year = False
default hour = 6
default minute = 00
default ampm = "am"
default current_time = "Early Morning"
default player_cash = 0

screen button():
    fixed:
        if day_button_switch:
            frame:
                xalign 0.0
                yalign 0.0
                vbox:
                    text "[month] [current_date], [current_year], [current_weekday]"
                    text "[hour]:[minute] [ampm] - [current_time]"
        if credit_button_switch:
            frame:
                xalign 1.0
                yalign 0.0
                vbox:
                    text "$ [player_cash]"

## The game starts here.

label start:
    show screen button()
    scene black
    "Hello. Your game has started and you can't see any parts of the button screen."
    $day_button_switch=True
    "Now the day should be visible."
    $credit_button_switch=True
    "Now the credit should be visible."
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
ninjew_42
Newbie
Posts: 4
Joined: Fri Jul 13, 2018 10:01 pm
Tumblr: glompme
Contact:

Re: Screens to track date/time not showing [solved]

#3 Post by ninjew_42 »

Thanks. I updated my code like you said and put in the show screen button code. Which I forgot to put in. My bad.

Everything is fine now.
Most people in my experience wouldn't know reason if it walked up and shook their hand. You can count Gul Dukat among them.

Post Reply

Who is online

Users browsing this forum: Google [Bot]