Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
BlackRam-oss committed Sep 11, 2023
1 parent 555f148 commit ec4f868
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions game/nqtr_values/time_value.rpy
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
define timeslot_names = [
(2, _("Night")),
(8, _("Morning")),
(14, _("Afternoon")),
(20, _("Evening")),
(19, _("Evening")),
(22, _("Night")),
]
define weekday_names = [
_("{#weekday}Monday"),
Expand Down
12 changes: 6 additions & 6 deletions pythonpackages/nqtr/time.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,7 @@ def weekday_names(self, value: list[str]):
def timeslot_name(self) -> str:
"""Returns the name of the current timeslot."""
if len(self.timeslot_names) > 0:
for timeslot in self.timeslot_names:
if self.hour >= timeslot[0]:
return timeslot[1]
return self.timeslot_names[len(self.timeslot_names)][1]
return self.timeslot_names[self.timeslot_number][1]
else:
log_warn(
"You have not set any timeslot_names, so it will return an empty string.",
Expand All @@ -135,10 +132,13 @@ def timeslot_number(self) -> int:
This variable is used to update images that change according to time.
es: image = "sky-[tm.timeslot_number]"""
res = 0
current = None
if len(self.timeslot_names) > 0:
for index, timeslot in enumerate(self.timeslot_names):
if self.hour >= timeslot[0] and index > res:
res = index
if self.hour >= timeslot[0]:
if current == None or timeslot[0] > current[0]:
res = index
current = timeslot
return res
else:
log_error(
Expand Down

0 comments on commit ec4f868

Please sign in to comment.