I need some displaying a python variable in ren'py navigation screen

EvilUser

Member
Game Developer
Mar 29, 2018
309
983
I have a daily cycle system, made in python but I have problem getting the number of day, day and time of day to display in screen in renpy
 

Palanto

Active Member
Game Developer
Oct 4, 2017
964
1,839
Hmm, well do you already have the basic code for your time of day and so on? Maybe show it to us so we can try figure out what you did / how you did it and what you need to do to show it on the screen? :)
 

EvilUser

Member
Game Developer
Mar 29, 2018
309
983
Yeah, I do... It's working fine, it's just that I don't know how to get Day #, day (mon, tue, wed, etc.) and time of day (morning, noon...) to get them into screen text
You don't have permission to view the spoiler content. Log in or register now.
 

Epadder

Programmer
Game Developer
Oct 25, 2016
568
1,061
When you're doing string replacement, you still need to use quotes around the brackets. The obvious problem is that, there could be another.

Code:
text = "[clock.weekday]" size 36 color "#ffffff" font "agencyb.ttf" xpos 20 ypos 50
text = "[clock.day]" size 32 color "#ffffff" font "agencyb.ttf" xpos 120 ypos 90
text = "[clock.time]" size 32 color "#ffffff" font "agencyb.ttf" xpos 250 ypos 70
 

EvilUser

Member
Game Developer
Mar 29, 2018
309
983
When your doing string replacement, you still need to use quotes around the brackets. The obvious problem is that, there could be another.

Code:
text = "[clock.weekday]" size 36 color "#ffffff" font "agencyb.ttf" xpos 20 ypos 50
text = "[clock.day]" size 32 color "#ffffff" font "agencyb.ttf" xpos 120 ypos 90
text = "[clock.time]" size 32 color "#ffffff" font "agencyb.ttf" xpos 250 ypos 70
I literally tried everything I know, that was the last try before I given up and asked here
 

Epadder

Programmer
Game Developer
Oct 25, 2016
568
1,061
if you open the console and use, print clock.weekday/clock.day/clock.time it does return a valid string?
 

Palanto

Active Member
Game Developer
Oct 4, 2017
964
1,839
Yeah, I do... It's working fine, it's just that I don't know how to get Day #, day (mon, tue, wed, etc.) and time of day (morning, noon...) to get them into screen text
You don't have permission to view the spoiler content. Log in or register now.
hmh ok the problem here is that you're using text in a way I've never seen before :D

try:
Code:
screen ngui:
    text "%s" %clock.weekday() size 36 color "#ffffff" font "agencyb.ttf" xpos 20 ypos 50
    text "%s" %clock.day() size 32 color "#ffffff" font "agencyb.ttf" xpos 120 ypos 90
    text "%s" %clock.time() size 32 color "#ffffff" font "agencyb.ttf" xpos 250 ypos 70
also why is the function:
Code:
def time(self):
            return self.time_of_day[0]
always and only returning "Morning"?
 

EvilUser

Member
Game Developer
Mar 29, 2018
309
983
hmh ok the problem here is that you're using text in a way I've never seen before :D

try:
Code:
screen ngui:
    text "%s" %clock.weekday() size 36 color "#ffffff" font "agencyb.ttf" xpos 20 ypos 50
    text "%s" %clock.day() size 32 color "#ffffff" font "agencyb.ttf" xpos 120 ypos 90
    text "%s" %clock.time() size 32 color "#ffffff" font "agencyb.ttf" xpos 250 ypos 70
also why is the function:
Code:
def time(self):
            return self.time_of_day[0]
always and only returning "Morning"?
No errors on run, but it doesn't show anything
 

Palanto

Active Member
Game Developer
Oct 4, 2017
964
1,839
ugh yeah can't show anything because I forgot to add some brackets :D

it should be like this actually:
text ["%s" %clock.weekday()] size 36 color "#ffffff" font "agencyb.ttf" xpos 20 ypos 50
 

Palanto

Active Member
Game Developer
Oct 4, 2017
964
1,839
X_x hmmm heck give me a minute I'll try your class and the screen in an empty game
 

Epadder

Programmer
Game Developer
Oct 25, 2016
568
1,061
The other thing is, where are you calling/showing ngui?
Also just to make sure you can even see the screen period, add some kind of image and center it in the screen.
I'd also recommend reading over
Especially post #10.
 

EvilUser

Member
Game Developer
Mar 29, 2018
309
983
label start:
"Some text"
call screen ngui
"Some more text"
show eilen happy

e "You've created a new Ren'Py game."

e "Once you add a story, pictures, and music, you can release it to the world!"
return
 

EvilUser

Member
Game Developer
Mar 29, 2018
309
983
Tried with backrounds, calling other screens with imagemaps and buttons, everything else is working
 

Palanto

Active Member
Game Developer
Oct 4, 2017
964
1,839
Uhm.... remove the -> () <- in the method I gave you and it works....