This easy recipe allow for characters to greet you at game launch, as for Tokimeki Memorial 3, BEFORE the main menu.
It also show how you can use the internal device clock ("locale") to differentiate events between night and day.
At first we import time module, that contain gmtime (get the device time) and strftime (it turn the time into a readable string format).
We check if the game has been launched at least once, if not the whole greeting phase is dropped.
This is a basic check, in more advanced code you'll want to display the main character of the last ending reached, or the higher love score owner. !!You need to use a persistent variable!! So for example a persistent that register the last ending reached or the actual love scores.
Then we turn the time value (abstract) stored in gmtime() into a readable string thanks to strftime(), and put it into the 'hour' variable.
Strftime have a lot of possible arguments, in this given case we'll use just "H%", the hours.
Here's a list of most common directives.
%a Locale’s abbreviated weekday name.
%A Locale’s full weekday name.
%b Locale’s abbreviated month name.
%B Locale’s full month name.
%d Day of the month as a decimal number [01,31].
%H Hour (24-hour clock) as a decimal number [00,23].
%I Hour (12-hour clock) as a decimal number [01,12].
%j Day of the year as a decimal number [001,366].
%m Month as a decimal number [01,12].
%M Minute as a decimal number [00,59].
%p Locale’s equivalent of either AM or PM.
%S Second as a decimal number [00,61].
%y Year without century as a decimal number [00,99].
%Y Year with century as a decimal number.
so you can write something like...
Code: Select all
$ vari=strftime("%A, %B %d. %I:%M", gmtime())
e "[vari]"
"Monday, February 25. 9:45"
** Remember you have to IMPORT the strftime and gmtime modules at init phase, or this doesn't work and throw an error.
Strftime always return strings, not numbers (hour="11", that's not the number 11 but a string of text, so no possible math operations)... Using an int() method we cheat the system and change it into an integer.
What's left is to decide what to show based on that integer.
Code: Select all
init python:
import time
label splashscreen:
# greet the player based on daytime
# ... but only if you launched the game at least once before!
if persistent.launched==None:
return
scene bg room
$ hour=time.strftime("%H",time.gmtime())
$ hour=int(hour)
if hour >8 and hour <22:
show eileen happy
e "Good morning! I was waiting for you! Let's have fun together!"
else:
show eileen sleepy
e "Yawn... You're really all about me, but please try to sleep in a while!"
return
label start:
$ persistent.launched=True
e "That's my game!"
return
SOME NOTE
Use quick and small tenses, that's just a candy and the player is feeling the urge of begin a new game!
Reloading the game when developing could have this scene repeat. Don't mind, it doesn't happen in a distributed game.
The lack of the quick menu is intentional, proper and necessary. The game is not actually started, you can't save or set options.
You can display WHATEVER, included images, animations and any screen.