When you start the game I want it to say Day 1 at the top left corner of the screen.
When a new day starts I want to be able to change it from Day 1 to Day 2, ect.
I want to be able to hide this counter at any time and have it work when you load a save or rollback to a previous day.
This post is the closest thing to what I'm trying to add: viewtopic.php?t=40548
Would it be easier to just show/hide an image of it, or am I just making more work for myself?
Thank you for you time.
How can I add a simple day counter?
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.
-
Charmareian
- Newbie
- Posts: 2
- Joined: Fri Aug 28, 2020 5:57 pm
- Contact:
Re: How can I add a simple day counter?
Hello Charmareian, put this in your "screens.rpy":
#Screen for Daytime-Week. And skip time symbol.
screen day_time_viewer:
zorder 405
if day_time==1:
imagebutton:
xpos 1130
ypos 0
focus_mask True
idle Transform("gui/Hud1-Morning.png", zoom=.8)
hover Transform("gui/Hud1-Morning.png", zoom=.8)
if day_time==2:
imagebutton:
xpos 1130
ypos 0
focus_mask True
idle Transform("gui/Hud2-Afternoon.png", zoom=.8)
hover Transform("gui/Hud2-Afternoon.png", zoom=.8)
if day_time==3:
imagebutton:
xpos 1130
ypos 0
focus_mask True
idle Transform("gui/Hud3-Evening.png", zoom=.8)
hover Transform("gui/Hud3-Evening.png", zoom=.8)
if day_time==4:
imagebutton:
xpos 1130
ypos 0
focus_mask True
idle Transform("gui/Hud4-Night.png", zoom=.8)
hover Transform("gui/Hud4-Night.png", zoom=.8)
screen week_day_viewer:
zorder 403
if week_day==1:
imagebutton:
xpos 1130
ypos 0
focus_mask True
idle Transform("gui/1Monday.png", zoom=.8)
hover Transform("gui/1Monday.png", zoom=.8)
if week_day==2:
imagebutton:
xpos 1130
ypos 0
focus_mask True
idle Transform("gui/2Tuesday.png", zoom=.8)
hover Transform("gui/2Tuesday.png", zoom=.8)
if week_day==3:
imagebutton:
xpos 1130
ypos 0
focus_mask True
idle Transform("gui/3Wednesday.png", zoom=.8)
hover Transform("gu/3Wednesday.png", zoom=.8)
if week_day==4:
imagebutton:
xpos 1130
ypos 0
focus_mask True
idle Transform("gui/4Thursday.png", zoom=.8)
hover Transform("gui/4Thursday.png", zoom=.8)
if week_day==5:
imagebutton:
xpos 1130
ypos 0
focus_mask True
idle Transform("gui/5Friday.png", zoom=.8)
hover Transform("gui/5Friday.png", zoom=.8)
if week_day==6:
imagebutton:
xpos 1130
ypos 0
focus_mask True
idle Transform("gui/6Saturday.png", zoom=.8)
hover Transform("gui/6Saturday.png", zoom=.8)
if week_day==7:
imagebutton:
xpos 1130
ypos 0
focus_mask True
idle Transform("gui/7Sunday.png", zoom=.8)
hover Transform("gui/7Sunday.png", zoom=.8)
screen time_skip_button:
zorder 403
if in_map==True:
imagebutton:
xpos 1770
ypos 0.0
focus_mask True
idle Transform("gui/Skip_Icon_Idle.png", zoom=.4)
hover Transform("gui/Skip_Icon_Hover.png", zoom=.4)
clicked [SetVariable("day_time", day_time + 1, ), Show("time_skip_button"), Jump("House_Map")]
hovered Show("displayTextScreen", displayText = "Skip Time")
unhovered Hide("displayTextScreen")
if day_time==4:
imagebutton:
xpos 1770
ypos 0.0
focus_mask True
idle Transform("gui/No_Skip_Icon_Hover.png", zoom=.4)
hover Transform("gui/No_Skip_Icon_Idle.png", zoom=.4)
clicked [SetVariable("day_time", 4), Show("time_skip_button"), Jump("House_Map")]
hovered Show("displayTextScreen", displayText = "Skip Time")
unhovered Hide("displayTextScreen")
if in_map==False:
imagebutton:
xpos 1770
ypos 0.0
focus_mask True
idle Transform("gui/No_Skip_Icon_Hover.png", zoom=.4)
hover Transform("gui/No_Skip_Icon_Idle.png", zoom=.4)
clicked [Show("time_skip_button"),]
hovered Show("displayTextScreen", displayText = "Skip Time")
unhovered Hide("displayTextScreen")
screen displayTextScreen:
key "hide_windows" action NullAction()
zorder 100
default displayText = ("")
vbox:
xalign 0.5
yalign 0.01
frame:
style "frame_gui1"
text "{size=+6}[displayText]{/size}"
This in your script.rpy before the "label Start:":
init python:
import datetime
class GameTime(object):
def __init__(self, dt="01 Apr 1518"):
self._dt = datetime.datetime.strptime( dt, "%d %b %Y" )
def alter(self, **kwargs):
self._dt += datetime.timedelta( **kwargs )
def __repr__(self):
return _strftime("%d %b %Y %H:%M", self._dt.timetuple())
#M-77 To do, some variable error is here, because of the year -out of range- tuple-something is wrong, when open developer console on 1st day calender is turned on, but it is all working well in game so no problem
@property
def tod(self):
return [ k[-1] for k in (
(1, "Morning"),
(2, "Afternoon"),
(3, "Evening"),
(4, "Night") ) if self._dt.hour in k ][0]
You may need to adjust this to your needs. And edit the screenbuttons too.
In game show the screens with:
show screen week_day_viewer
show screen day_time_viewer
show screen time_skip_button
And also can hide them.
And possible at some idle map you may need use this commands, I forgot what exactly they are for:
$ can_hide_windows = False
$ in_map=True #<- This disables the "Skip Time" function, if I remenber right.
Put the icons from the attach into your "game/gui/" directory.
Change the icons, screenbuttons to your needs with a Paintprogramm.
Good luck!
#Screen for Daytime-Week. And skip time symbol.
screen day_time_viewer:
zorder 405
if day_time==1:
imagebutton:
xpos 1130
ypos 0
focus_mask True
idle Transform("gui/Hud1-Morning.png", zoom=.8)
hover Transform("gui/Hud1-Morning.png", zoom=.8)
if day_time==2:
imagebutton:
xpos 1130
ypos 0
focus_mask True
idle Transform("gui/Hud2-Afternoon.png", zoom=.8)
hover Transform("gui/Hud2-Afternoon.png", zoom=.8)
if day_time==3:
imagebutton:
xpos 1130
ypos 0
focus_mask True
idle Transform("gui/Hud3-Evening.png", zoom=.8)
hover Transform("gui/Hud3-Evening.png", zoom=.8)
if day_time==4:
imagebutton:
xpos 1130
ypos 0
focus_mask True
idle Transform("gui/Hud4-Night.png", zoom=.8)
hover Transform("gui/Hud4-Night.png", zoom=.8)
screen week_day_viewer:
zorder 403
if week_day==1:
imagebutton:
xpos 1130
ypos 0
focus_mask True
idle Transform("gui/1Monday.png", zoom=.8)
hover Transform("gui/1Monday.png", zoom=.8)
if week_day==2:
imagebutton:
xpos 1130
ypos 0
focus_mask True
idle Transform("gui/2Tuesday.png", zoom=.8)
hover Transform("gui/2Tuesday.png", zoom=.8)
if week_day==3:
imagebutton:
xpos 1130
ypos 0
focus_mask True
idle Transform("gui/3Wednesday.png", zoom=.8)
hover Transform("gu/3Wednesday.png", zoom=.8)
if week_day==4:
imagebutton:
xpos 1130
ypos 0
focus_mask True
idle Transform("gui/4Thursday.png", zoom=.8)
hover Transform("gui/4Thursday.png", zoom=.8)
if week_day==5:
imagebutton:
xpos 1130
ypos 0
focus_mask True
idle Transform("gui/5Friday.png", zoom=.8)
hover Transform("gui/5Friday.png", zoom=.8)
if week_day==6:
imagebutton:
xpos 1130
ypos 0
focus_mask True
idle Transform("gui/6Saturday.png", zoom=.8)
hover Transform("gui/6Saturday.png", zoom=.8)
if week_day==7:
imagebutton:
xpos 1130
ypos 0
focus_mask True
idle Transform("gui/7Sunday.png", zoom=.8)
hover Transform("gui/7Sunday.png", zoom=.8)
screen time_skip_button:
zorder 403
if in_map==True:
imagebutton:
xpos 1770
ypos 0.0
focus_mask True
idle Transform("gui/Skip_Icon_Idle.png", zoom=.4)
hover Transform("gui/Skip_Icon_Hover.png", zoom=.4)
clicked [SetVariable("day_time", day_time + 1, ), Show("time_skip_button"), Jump("House_Map")]
hovered Show("displayTextScreen", displayText = "Skip Time")
unhovered Hide("displayTextScreen")
if day_time==4:
imagebutton:
xpos 1770
ypos 0.0
focus_mask True
idle Transform("gui/No_Skip_Icon_Hover.png", zoom=.4)
hover Transform("gui/No_Skip_Icon_Idle.png", zoom=.4)
clicked [SetVariable("day_time", 4), Show("time_skip_button"), Jump("House_Map")]
hovered Show("displayTextScreen", displayText = "Skip Time")
unhovered Hide("displayTextScreen")
if in_map==False:
imagebutton:
xpos 1770
ypos 0.0
focus_mask True
idle Transform("gui/No_Skip_Icon_Hover.png", zoom=.4)
hover Transform("gui/No_Skip_Icon_Idle.png", zoom=.4)
clicked [Show("time_skip_button"),]
hovered Show("displayTextScreen", displayText = "Skip Time")
unhovered Hide("displayTextScreen")
screen displayTextScreen:
key "hide_windows" action NullAction()
zorder 100
default displayText = ("")
vbox:
xalign 0.5
yalign 0.01
frame:
style "frame_gui1"
text "{size=+6}[displayText]{/size}"
This in your script.rpy before the "label Start:":
init python:
import datetime
class GameTime(object):
def __init__(self, dt="01 Apr 1518"):
self._dt = datetime.datetime.strptime( dt, "%d %b %Y" )
def alter(self, **kwargs):
self._dt += datetime.timedelta( **kwargs )
def __repr__(self):
return _strftime("%d %b %Y %H:%M", self._dt.timetuple())
#M-77 To do, some variable error is here, because of the year -out of range- tuple-something is wrong, when open developer console on 1st day calender is turned on, but it is all working well in game so no problem
@property
def tod(self):
return [ k[-1] for k in (
(1, "Morning"),
(2, "Afternoon"),
(3, "Evening"),
(4, "Night") ) if self._dt.hour in k ][0]
You may need to adjust this to your needs. And edit the screenbuttons too.
In game show the screens with:
show screen week_day_viewer
show screen day_time_viewer
show screen time_skip_button
And also can hide them.
And possible at some idle map you may need use this commands, I forgot what exactly they are for:
$ can_hide_windows = False
$ in_map=True #<- This disables the "Skip Time" function, if I remenber right.
Put the icons from the attach into your "game/gui/" directory.
Change the icons, screenbuttons to your needs with a Paintprogramm.
Good luck!
- Attachments
-
- frame_gui1.png (1.83 KiB) Viewed 430 times
-
- 2Tuesday.png (993 Bytes) Viewed 430 times
-
- 1Monday.png (1.02 KiB) Viewed 430 times
-
- 3Wednesday.png (1.13 KiB) Viewed 430 times
-
- 7Sunday.png (916 Bytes) Viewed 430 times
-
- 6Saturday.png (936 Bytes) Viewed 430 times
-
- 5Friday.png (890 Bytes) Viewed 430 times
-
- 4Thursday.png (1.06 KiB) Viewed 430 times
-
- No_Skip_Icon_Idle.png (1.71 KiB) Viewed 430 times
-
- No_Skip_Icon_Hover.png (1.71 KiB) Viewed 430 times
-
- Skip_Icon_Idle.png (215 Bytes) Viewed 430 times
-
- Skip_Icon_Hover.png (215 Bytes) Viewed 430 times
-
- Hud1-Morning.png (3.4 KiB) Viewed 430 times
-
- Hud4-Night.png (3.33 KiB) Viewed 430 times
-
- Hud3-Evening.png (3.44 KiB) Viewed 430 times
-
- Hud2-Afternoon.png (3.47 KiB) Viewed 430 times
Re: How can I add a simple day counter?
I don't know if you are aware of the renpy.notify function, this shows a notification at the top left of the corner with any information given, hides automatically after 3 or 4 seconds.
in this example is linked to a variable, everytime you jump to a label this will show, but it wont work saving and loading, as the loading is probably loaded in any part of the code where it was left and requires a more complex code.
every time you got to the Waking_up label it will add 1 to the day counter and show it, it will do the same for the school label.
in this example is linked to a variable, everytime you jump to a label this will show, but it wont work saving and loading, as the loading is probably loaded in any part of the code where it was left and requires a more complex code.
every time you got to the Waking_up label it will add 1 to the day counter and show it, it will do the same for the school label.
Code: Select all
$ days_number = 0
label Waking_up:
$ days_number += 1 #adds one to the counter
$ renpy.notify("day: " + str(days_number)) #displays the variable with the number of days
"text to fill replace with anything"
label School:
$ days_number += 1
$ renpy.notify("day: " + str(days_number))
"text to fill replace with anything"
Re: How can I add a simple day counter?
And I need to add to my above code:
Set time in game after "label start" with:
$ day_time = 4 #This will set your day time to night, 1 for morning etc.
$ week_day = 1 #This will set your week day to monday
In game when time has to pass in an event for example:
$ day_time += 1
If you send your character to slep at time 4 night let this code run, so you start on a morning after this and on next day:
$ day_time += 1
$ week_day += 1
if day_time == 5:
$ day_time = 1
if week_day == 8:
$ week_day = 1
Set time in game after "label start" with:
$ day_time = 4 #This will set your day time to night, 1 for morning etc.
$ week_day = 1 #This will set your week day to monday
In game when time has to pass in an event for example:
$ day_time += 1
If you send your character to slep at time 4 night let this code run, so you start on a morning after this and on next day:
$ day_time += 1
$ week_day += 1
if day_time == 5:
$ day_time = 1
if week_day == 8:
$ week_day = 1
Who is online
Users browsing this forum: Google [Bot]