How do I make certain things happen on certain dates?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Amateur.game.dev.

So, a bit like how games such as GTA snows on christmas and Minecraft’s chests look like presents on Christmas Eve/Day/Boxing Day, I was wondering if there was a way i could implement some thing like this into my game?
What I want to happen is, the main menu background to change as different seasons occur:

In Autumn there are leaves falling (particles)

In winter the trees will have bits of white on them to represent snow and there will be snow particles

In spring there will be a bright sun behind the clouds and there will be animals flying

In summer the sky will be bare with just the sun and the leaves will be a darker green

This will also happen in-game, where the tiles/trees will have leaves/snow/flowers/grass on them, depending on the season.

I think that timers will be able to do this, but I was thinking that maybe there is a plugin available that allows me to implement certain things on certain dates(like a calendar outside of the actual game).

:bust_in_silhouette: Reply From: klaas

Hi,
you can use this functions of the OS object

var dateDict = OS.get_date()

Dictionary get_date ( bool utc=false ) const
Returns current date as a dictionary of keys: year, month, day, weekday, dst (Daylight Savings Time).

Dictionary get_datetime ( bool utc=false ) const
Returns current datetime as a dictionary of keys: year, month, day, weekday, dst (Daylight Savings Time), hour, minute, second.

Could you possibly say how I would implement this into a function? Thanks

Amateur.game.dev. | 2020-09-23 19:27

func _ready():
	var dateDict = OS.get_date()
	if dateDict["day"] == 24 and dateDict["month"] == 12:
		print("Ho Ho Ho")

klaas | 2020-09-24 08:13

Thank you so much! This works perfectly, all I had to do extra was to make the trees automatically invisible and on certain months only show one. Again, thank you!!

Amateur.game.dev. | 2020-09-25 13:38