Hello
I am back for another question, can somebody help me of having the time counting of the game/playtime on screen?
And also, when the player finishes the game, or having the ending finished, the time will stop and it will display in the text dialogue for how much time consumed of playing that game. And quits the game.
Thanks for who could help.
Displaying playtime
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.
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.
- isobellesophia
- Miko-Class Veteran
- Posts: 979
- Joined: Mon Jan 07, 2019 2:55 am
- Completed: None
- Projects: Maddox and Friends! (AI Teacher friend), Friendly Universities! (Soon)
- Organization: Friendly Teachers series
- Deviantart: SophBelle
- itch: Child Creation
- Location: Philippines, Mindanao
- Contact:
- Imperf3kt
- Lemma-Class Veteran
- Posts: 3794
- Joined: Mon Dec 14, 2015 5:05 am
- itch: Imperf3kt
- Location: Your monitor
- Contact:
Re: Displaying playtime
I'm not sure how useful it is to you but I use this on the save screen:
It allows each save file to display its own runtime as text on the save screen.
I imagine you could modify it to display at the end of a playthrough with minimal work.
Code: Select all
init python:
import time
## game runtime counter
default playtime = 0
init 2 python:
def save_playtime(d):
renpy.store.playtime += renpy.get_game_runtime()
renpy.clear_game_runtime()
d["playtime"] = renpy.store.playtime
config.save_json_callbacks = [save_playtime]
############## The above can go anywhere in the screens file ############
text FileTime(slot, format=_("{#file_time}%A, %B %d %Y, %H:%M"), empty=_("empty slot")):
style "slot_time_text"
$ playtime = FileJson(slot, "playtime", empty=0, missing=0)
$ minutes, seconds = divmod(int(playtime), 60)
$ hours, minutes = divmod(minutes, 60)
text "Playtime: [hours:02d]:[minutes:02d].[seconds:02]":
style "slot_time_text"
style page_label is gui_label
style page_label_text is gui_label_text
style page_button is gui_button
style page_button_text is gui_button_text
style slot_button is gui_button
style slot_button_text is gui_button_text
style slot_time_text is slot_button_text
style slot_name_text is slot_button_text
style page_label:
xpadding 50
ypadding 3
style page_label_text:
text_align 0.5
layout "subtitle"
hover_color gui.hover_color
style page_button:
properties gui.button_properties("page_button")
style page_button_text:
properties gui.button_text_properties("page_button")
style slot_button:
properties gui.button_properties("slot_button")
style slot_button_text:
properties gui.button_text_properties("slot_button")
I imagine you could modify it to display at the end of a playthrough with minimal work.
Warning: May contain trace amounts of gratuitous plot.
pro·gram·mer (noun) An organism capable of converting caffeine into code.
Current project: GGD Mentor
Twitter
pro·gram·mer (noun) An organism capable of converting caffeine into code.
Current project: GGD Mentor
- isobellesophia
- Miko-Class Veteran
- Posts: 979
- Joined: Mon Jan 07, 2019 2:55 am
- Completed: None
- Projects: Maddox and Friends! (AI Teacher friend), Friendly Universities! (Soon)
- Organization: Friendly Teachers series
- Deviantart: SophBelle
- itch: Child Creation
- Location: Philippines, Mindanao
- Contact:
Re: Displaying playtime
Im sorry to say, but when i tried this, the playtime wont count as i play fowardly the game, is there any i can use to work?Imperf3kt wrote: ↑Sun Oct 06, 2019 6:03 am I'm not sure how useful it is to you but I use this on the save screen:It allows each save file to display its own runtime as text on the save screen.Code: Select all
init python: import time ## game runtime counter default playtime = 0 init 2 python: def save_playtime(d): renpy.store.playtime += renpy.get_game_runtime() renpy.clear_game_runtime() d["playtime"] = renpy.store.playtime config.save_json_callbacks = [save_playtime] ############## The above can go anywhere in the screens file ############ text FileTime(slot, format=_("{#file_time}%A, %B %d %Y, %H:%M"), empty=_("empty slot")): style "slot_time_text" $ playtime = FileJson(slot, "playtime", empty=0, missing=0) $ minutes, seconds = divmod(int(playtime), 60) $ hours, minutes = divmod(minutes, 60) text "Playtime: [hours:02d]:[minutes:02d].[seconds:02]": style "slot_time_text" style page_label is gui_label style page_label_text is gui_label_text style page_button is gui_button style page_button_text is gui_button_text style slot_button is gui_button style slot_button_text is gui_button_text style slot_time_text is slot_button_text style slot_name_text is slot_button_text style page_label: xpadding 50 ypadding 3 style page_label_text: text_align 0.5 layout "subtitle" hover_color gui.hover_color style page_button: properties gui.button_properties("page_button") style page_button_text: properties gui.button_text_properties("page_button") style slot_button: properties gui.button_properties("slot_button") style slot_button_text: properties gui.button_text_properties("slot_button")
I imagine you could modify it to display at the end of a playthrough with minimal work.
- isobellesophia
- Miko-Class Veteran
- Posts: 979
- Joined: Mon Jan 07, 2019 2:55 am
- Completed: None
- Projects: Maddox and Friends! (AI Teacher friend), Friendly Universities! (Soon)
- Organization: Friendly Teachers series
- Deviantart: SophBelle
- itch: Child Creation
- Location: Philippines, Mindanao
- Contact:
Re: Displaying playtime
Im sorry to say, is there any code i can use? This one does not work, it doesnt count the playtime as i tried it.
- Imperf3kt
- Lemma-Class Veteran
- Posts: 3794
- Joined: Mon Dec 14, 2015 5:05 am
- itch: Imperf3kt
- Location: Your monitor
- Contact:
Re: Displaying playtime
Sorry, its something I lifted from a cookbook entry.
I'm not too well versed in the json behind it (or at all, really)
Perhaps somebody else can help further.
I'm not too well versed in the json behind it (or at all, really)
Perhaps somebody else can help further.
Warning: May contain trace amounts of gratuitous plot.
pro·gram·mer (noun) An organism capable of converting caffeine into code.
Current project: GGD Mentor
Twitter
pro·gram·mer (noun) An organism capable of converting caffeine into code.
Current project: GGD Mentor
- isobellesophia
- Miko-Class Veteran
- Posts: 979
- Joined: Mon Jan 07, 2019 2:55 am
- Completed: None
- Projects: Maddox and Friends! (AI Teacher friend), Friendly Universities! (Soon)
- Organization: Friendly Teachers series
- Deviantart: SophBelle
- itch: Child Creation
- Location: Philippines, Mindanao
- Contact:
Re: Displaying playtime
Nvm, you edited the code, thanks for the help!
Who is online
Users browsing this forum: No registered users