*** Original post start here ***
I was following the code from the Cookbook post: Scarily simple game calendar... with day parts and it works perfectly with a few custom changes for my needs. I created a "calendar.rpy" file to contain the code.
Code: Select all
# calendar.rpy
init python:
import datetime
class GameTime(object):
def __init__(self, dt="Saturday, April 29 2017"):
self._dt = datetime.datetime.strptime( dt, "%A, %B %d %Y" )
def alter(self, **kwargs):
self._dt += datetime.timedelta( **kwargs )
def __repr__(self):
return _strftime("%I:%M %p %A, %B %d,"" %Y", self._dt.timetuple())
@property
def daymark(self):
return [ k[-1] for k in (
(0, "Midnight"),
(1,2,3,4,5, "Very Early Morning"),
(6,7, "Early Morning"),
(8,9, "Morning"),
(10,11, "Mid-Morning"),
(12, "Noon"),
(13,14,15, "Afternoon"),
(16,17, "Mid-Afternoon"),
(18,19, "Evening"),
(20,21, "Night"),
(22,23, "Late Night") ) if self._dt.hour in k ][0]
default gt = GameTime("Saturday, April 29 2017")
Code: Select all
$ gts.alter( hours = 6, minutes = 0 ) # Set for 6 AM of started day in code
Code: Select all
"[gt.daymark]" # Shows up on screen: Early Morning
Code: Select all
"[gt]" # Shows up on screen: 6:00 AM Saturday, April 29 2017
6:00 AM
And to have just the date displayed:
Saturday, April 29 2017
I need the output "[gt.daymark]" and "[gt]" formats at different times in the story script but would like to be able to have the last 2 mentioned with it also if it's possible.
I have looked, googled and tried numerous Python codes with no luck since I am a novice. I guess their answers do not play nice with the code that "Remix" posted.
I hope that someone could be kind enough to show me the way if possible?
Thank you for your time!