-
-
Notifications
You must be signed in to change notification settings - Fork 10
Time system
Time system is a system that allows you to manage the time of the game. The class that handles Time is TimeHandler.
INFO: For don't create problems if you not implement this in your project, the tm
are not defined by default empty. BUT, if you use the dict without initializing it, the system not save the changes.
For implement this you need to add this in your project:
define timeslot_names = [
(2, _("Night")),
(8, _("Morning")),
(14, _("Afternoon")),
(20, _("Evening")),
]
define weekday_names = [
_("{#weekday}Monday"),
_("{#weekday}Tuesday"),
_("{#weekday}Wednesday"),
_("{#weekday}Thursday"),
_("{#weekday}Friday"),
_("{#weekday}Saturday"),
_("{#weekday}Sunday")
]
# ATTENTION here it is initialized
# when a save is loaded it is created with the updateTimeHandler() function
default tm = TimeHandler(
hour_of_new_day = 5,
hour = 8,
weekday_weekend_begins = 6,
day = 0,
timeslot_names = timeslot_names,
weekday_names = weekday_names
)
(code-snippets: DR_NewDay
)
call new_day
call new_day(time_of_new_day = 9)
(code-snippets: DR_Wait
)
call wait
call wait(wait_hour = 3)
(code-snippets: DR_NowIsBetween
)
Check if the current time is between start and end
if (now_is_between(start=routine.hour_start, end=routine.hour_stop)):
# ...
if tm.is_weekend:
# ...
you can use tm.weekday_number to determine what day of the week you are on.
example:
if tm.weekday_number == 0:
# Monday
if tm.weekday_number == 1:
# Tuesday
if tm.weekday_number == 2:
# Wednesday
# ...
define weekday_names = [
_("{#weekday}Monday"),
_("{#weekday}Tuesday"),
_("{#weekday}Wednesday"),
_("{#weekday}Thursday"),
_("{#weekday}Friday"),
_("{#weekday}Saturday"),
_("{#weekday}Sunday")
]
# pressing the hold button will increase the time of:
define DEFAULT_WAIT_HOUR = 1
# using the default new day function the time of the next day will be:
define DEFAULT_BLOCK_SPENDTIME_DIALOGUE = _("You can't do that now")
This functions are not recommended because not update update olther variables conditioned by time.
So is consigliabile use the label after_spending_time(is_check_event=False, is_check_routines=True)
after this functions.
I left the possibility of using them for those who want to follow in a python code. Or to customize some possibilities.
Procedure not recommended, use appropriate label.
Tip: use after_spending_time at the end
python:
new_day()
Procedure not recommended, use appropriate label.
Tip: use after_spending_time at the end.
python:
new_hour(3)
For block the spending time you can use the flag not_can_spend_time
:
You need to add the flag in the list of Flags:
# https://github.com/DRincs-Productions/renpy-utility-lib/wiki/Flags
define flag_keys = [
# Block all spend_time
"not_can_spend_time",
]
For example:
# to lock
$ set_flags("not_can_spend_time", False)
# to unlock
$ set_flags("not_can_spend_time", True)
You can use the tm.timeslot_number
to change the image based on the time period.
tm.timeslot_number
depends on the timeslot_names
list. The first element of the list is 0, the second is 1, and so on.
exemple:
define timeslot_names = [
(2, _("Night")), # tm.timeslot_number = 0
(8, _("Morning")), # tm.timeslot_number = 1
(14, _("Afternoon")), # tm.timeslot_number = 2
(20, _("Evening")), # tm.timeslot_number = 3
]
image bg annroom = "location/garden-[tm.timeslot_number].webp"