Suggestion for an on screen counter? [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
Suru
Regular
Posts: 111
Joined: Wed Aug 31, 2016 10:27 pm
Contact:

Suggestion for an on screen counter? [SOLVED]

#1 Post by Suru » Tue Jun 25, 2019 11:33 am

I am hoping to have a on screen counter with a 'number of minutes left' in it. I don't want a live counter that will actively count down. I plan to have a variable that will lower the time left as people choose particular actions so it doesn't matter how fast or slow they read through choices made. I would like to have a fairly simple display of the time left in the upper left of the screen, but I don't see any examples of this sort of code to work with. If anyone can direct me at suggestions I'd appreciate it.
Last edited by Suru on Tue Jun 25, 2019 3:39 pm, edited 1 time in total.

User avatar
Per K Grok
Miko-Class Veteran
Posts: 882
Joined: Fri May 18, 2018 1:02 am
Completed: the Ghost Pilot, Sea of Lost Ships, Bubbles and the Pterodactyls, Defenders of Adacan Part 1-3, the Phantom Flyer
itch: per-k-grok
Location: Sverige
Contact:

Re: Suggestion for an on screen counter?

#2 Post by Per K Grok » Tue Jun 25, 2019 12:31 pm

Suru wrote:
Tue Jun 25, 2019 11:33 am
I am hoping to have a on screen counter with a 'number of minutes left' in it. I don't want a live counter that will actively count down. I plan to have a variable that will lower the time left as people choose particular actions so it doesn't matter how fast or slow they read through choices made. I would like to have a fairly simple display of the time left in the upper left of the screen, but I don't see any examples of this sort of code to work with. If anyone can direct me at suggestions I'd appreciate it.
You need a variable to hold the numbers of 'minutes' left. You write that out in a screen.
When ever something happens in the script you count down the value of the variable and activate screen to show the updated value.

Code: Select all


default countdown=100

screen counter():
    text "Minutes left: " + str(countdown)
    
    
label start:    
    show screen counter
    
    --- stuff happening ---
    $ countdown -=1
    show screen counter
 
 

User avatar
Suru
Regular
Posts: 111
Joined: Wed Aug 31, 2016 10:27 pm
Contact:

Re: Suggestion for an on screen counter?

#3 Post by Suru » Tue Jun 25, 2019 12:37 pm

Thanks for replying. This I'm trying to work with. It just tells me: 'show' is not a keyword argument or valid child for the screen statement.

User avatar
Suru
Regular
Posts: 111
Joined: Wed Aug 31, 2016 10:27 pm
Contact:

Re: Suggestion for an on screen counter?

#4 Post by Suru » Tue Jun 25, 2019 1:33 pm

Per K Grok wrote:
Tue Jun 25, 2019 12:31 pm
Suru wrote:
Tue Jun 25, 2019 11:33 am
I am hoping to have a on screen counter with a 'number of minutes left' in it. I don't want a live counter that will actively count down. I plan to have a variable that will lower the time left as people choose particular actions so it doesn't matter how fast or slow they read through choices made. I would like to have a fairly simple display of the time left in the upper left of the screen, but I don't see any examples of this sort of code to work with. If anyone can direct me at suggestions I'd appreciate it.
You need a variable to hold the numbers of 'minutes' left. You write that out in a screen.
When ever something happens in the script you count down the value of the variable and activate screen to show the updated value.

Code: Select all


default countdown=100

screen counter():
    text "Minutes left: " + str(countdown)
    
    
label start:    
    show screen counter
    
    --- stuff happening ---
    $ countdown -=1
    show screen counter
 
 

User avatar
Per K Grok
Miko-Class Veteran
Posts: 882
Joined: Fri May 18, 2018 1:02 am
Completed: the Ghost Pilot, Sea of Lost Ships, Bubbles and the Pterodactyls, Defenders of Adacan Part 1-3, the Phantom Flyer
itch: per-k-grok
Location: Sverige
Contact:

Re: Suggestion for an on screen counter?

#5 Post by Per K Grok » Tue Jun 25, 2019 2:18 pm

Suru wrote:
Tue Jun 25, 2019 12:37 pm
Thanks for replying. This I'm trying to work with. It just tells me: 'show' is not a keyword argument or valid child for the screen statement.
That's puzzling. I did a test run of the script just to see that I had not slipped up somewhere.
I just replaced the pseudo line
---- stuff happens ----
and the code ran as expected.

Below the exact code I tested with.

Code: Select all

default countdown=100

screen counter():
    text "Minutes left: " + str(countdown)


label start:
    show screen counter

    "Hello Dolly"
    $ countdown -=1
    show screen counter
    "Success"
 

User avatar
Suru
Regular
Posts: 111
Joined: Wed Aug 31, 2016 10:27 pm
Contact:

Re: Suggestion for an on screen counter?

#6 Post by Suru » Tue Jun 25, 2019 3:39 pm

I got it working! Thanks very much! All the appreciation!

Per K Grok wrote:
Tue Jun 25, 2019 2:18 pm
Suru wrote:
Tue Jun 25, 2019 12:37 pm
Thanks for replying. This I'm trying to work with. It just tells me: 'show' is not a keyword argument or valid child for the screen statement.
That's puzzling. I did a test run of the script just to see that I had not slipped up somewhere.
I just replaced the pseudo line
---- stuff happens ----
and the code ran as expected.

Below the exact code I tested with.

Code: Select all

default countdown=100

screen counter():
    text "Minutes left: " + str(countdown)


label start:
    show screen counter

    "Hello Dolly"
    $ countdown -=1
    show screen counter
    "Success"
 

Post Reply

Who is online

Users browsing this forum: Google [Bot]