Events in different dates in BGE 2.79b

Hi all! I want to create a system that recognizes what day is it, and depending on the date different events will take place in the blend. For example, on April 1st (April’s Fools) instead of a “loading screen” we see a “downloading virus” screen.

I’m sure the first step (guessing the date) can easily be achieved via Python, but I’m not sure what should be done next. I think the “easiest” way would be to specify in the own script these special dates, and when we reach one of them the active object sends an unique Message for this date. From there, everything else takes place.

I don’t know if it’s too crazy to be done, of course I’m open to any ideas in which this system could be created! Thank you all for your time!

from datetime import date
today = date.today()
month, day = today.strftime("%m/%d").split("/")
month, day = int(month), int(day)

Will give you the current day and month as separate variables.

From there, it’s easy:

if month == 4 and day == 1:
    <april_fools_function()>

Or, if you have a loading_screen(message) function:

if month == 4 and day == 1:
    loading_screen(message="downloading virus")
else:
    loading_screen(message="loading game")
4 Likes

Thank you SO MUCH for your help! I messed around a little bit with the script and I think I finally got it:

import bge

from datetime import date
today = date.today()
month, day = today.strftime("%m/%d").split("/")
month, day = int(month), int(day)

if month == 5 and day == 18:
    bge.logic.sendMessage("delete")

I used today’s date and set up a Cube deleting itself when receiving the message “delete”. From here, I guess I can add as many “if month…sendMessage()” lines as I want. Any additional tips are always welcome, thank you again!!

1 Like

Awesome, I’m glad you got it working :slight_smile:

My code is a little messy, especially with the date handling, but it shouldn’t be too hard to clean that up if you end up needing it

1 Like