• To improve security, we will soon start forcing password resets for any account that uses a weak password on the next login. If you have a weak password or a defunct email, please update it now to prevent future disruption.

Does anyone know why this isn't showing up?

CherryPopKelo

Newbie
Game Developer
Feb 9, 2020
92
344
So here's the problem: You're trying to use variables before you've defined them. Renpy reads code one line at a time and it goes in order from top to bottom. If you want to display the day and time instantly after starting a new game, you need to define the day and time before the game starts.

What you can do is move this code:
output = day_name[day] + " " + str(hour).zfill(2) + ":" + str(minute).zfill(2)
to where you define output so it looks like this:
define output = day_name[day] + " " + str(hour).zfill(2) + ":" + str(minute).zfill(2)

If you try to run the game now, it will crash because all of those variables you want to reference (day_name, day, hour, minute) have not been defined yet. You can fix this by defining all of those variables BEFORE you define output:
define day_name = ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"]
define day = 0
define hour = 12
define minute = 0
define output = day_name[day] + " " + str(hour).zfill(2) + ":" + str(minute).zfill(2)


Or if you just want a quick fix, define output as whatever you want it to say right when the game starts and leave the rest of the code alone:
define output = "Monday 10:00"
I shall try this
 

CherryPopKelo

Newbie
Game Developer
Feb 9, 2020
92
344
So here's the problem: You're trying to use variables before you've defined them. Renpy reads code one line at a time and it goes in order from top to bottom. If you want to display the day and time instantly after starting a new game, you need to define the day and time before the game starts.

What you can do is move this code:
output = day_name[day] + " " + str(hour).zfill(2) + ":" + str(minute).zfill(2)
to where you define output so it looks like this:
define output = day_name[day] + " " + str(hour).zfill(2) + ":" + str(minute).zfill(2)

If you try to run the game now, it will crash because all of those variables you want to reference (day_name, day, hour, minute) have not been defined yet. You can fix this by defining all of those variables BEFORE you define output:
define day_name = ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"]
define day = 0
define hour = 12
define minute = 0
define output = day_name[day] + " " + str(hour).zfill(2) + ":" + str(minute).zfill(2)
tried defining it code and it is now showing the day and time but they do not change, what should i do with the loop?

while gamerunning:

$ minute += 30
if minute > 30:
$ minute = 0
$ hour += 1
if hour > 23:
$ hour = 0
$ day ++ 1
if day > 6:
$day += 1
 

SLDR

Uploader
Modder
Aug 5, 2016
202
1,151
tried defining it code and it is now showing the day and time but they do not change, what should i do with the loop?

while gamerunning:

$ minute += 30
if minute > 30:
$ minute = 0
$ hour += 1
if hour > 23:
$ hour = 0
$ day ++ 1
if day > 6:
$day += 1
That loop doesn't do what you think it does. That is an infinite loop where you keep clicking and it keeps advancing time by 30 minutes. It does not keep track of time while other things happen; Renpy is locked into that loop and can't do anything but advance time by 30 minutes forever. If you want to keep track of time, you need to look into creating your own screens and overlays. That allows you to display things in the background while the player is advancing the story.

This is getting beyond what I'm willing to do for free on a forum, so I'll leave you with two suggestions:

Download some games that have a time system you like and examine their code to try and understand how they made their time system work. Use those concepts to create your own time system for your game.

I would also highly recommend stripping down your current time system. I don't think I've ever played a game that needed to keep track of time down to the exact minute. Blocks of time like Morning/Afternoon/Evening/Night are easier to deal with in terms of code and storytelling.

Best of luck to you!
 

CherryPopKelo

Newbie
Game Developer
Feb 9, 2020
92
344
That loop doesn't do what you think it does. That is an infinite loop where you keep clicking and it keeps advancing time by 30 minutes. It does not keep track of time while other things happen; Renpy is locked into that loop and can't do anything but advance time by 30 minutes forever. If you want to keep track of time, you need to look into creating your own screens and overlays. That allows you to display things in the background while the player is advancing the story.

This is getting beyond what I'm willing to do for free on a forum, so I'll leave you with two suggestions:

Download some games that have a time system you like and examine their code to try and understand how they made their time system work. Use those concepts to create your own time system for your game.

I would also highly recommend stripping down your current time system. I don't think I've ever played a game that needed to keep track of time down to the exact minute. Blocks of time like Morning/Afternoon/Evening/Night are easier to deal with in terms of code and storytelling.

Best of luck to you!

Thank you for all you help, you did more than anyone else and i am grateful.

I had an idea on how to do an inventory system but i looked a few up and there all using statement that i have not learned yet and dont really think is necessary for my game so i attempted my way of the inventory and it worked flawlessly first time.
That game me an idea on a day system which is limited on what i can do with it but will still work for my game.

Thank you again!!!

P.s. I tried to look at some code for a game i have installed that had a clock like what i wanted to kind of mimic with that code i gave you but the script options were all grade out, does that mean developer mode is turned of?