Night cycle help

It has a way to capture hours of the computer and put a variable in C ++?
I never used C ++ in my life
I want to do a night cycle in the game :frowning:
(Sorry for bad english,im brazillian)

Do you want it to be night time in the game when it’s night time in real life, or just have a way to switch between day and night after a certain amount of time has passed in the game?

Real time

That’s harder, assuming GDevelop doesn’t have a way to access the onboard clock and put it in a variable. You could use a text entry object to ask the player for the time when they start the game.

After some stackoverflow-ing I’ve managed to get some working code for both Native and Web platforms, if anyone is interested:

GetDateTime_cpp.gdg (7.15 KB)
GetDateTime_javascript.gdg (6.44 KB)

Lizard-13, is there a simple way to give minutes and seconds a leading 0 if it’s a single digit? I know you could use events to add the 0, but I was wondering about in the code.

Yeah, but the variable should be saved as a string to add the extra zero, so make sure GD converts correctly the string “05” to the number 5 when you need to check numerical values:

GetDateTime_cpp.gdg (7.31 KB)
GetDateTime_javascript.gdg (6.72 KB)

Anyway making it with GD events is pretty easy :wink:

Thank you :smiley: :smiley:

I know, but if it’s in C++ and Javascript already, it’s ready to be dropped into GDevelop as an action. I was going to suggest that it’s a new feature, or an extension, in a future release of the program. It’s something else that most other game making programs I’ve tried don’t have in a “ready to use” function.