Discuss how to use the Ren'Py engine to create visual novels and story-based games. New releases are announced in this section.
Forum rules
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
screen jx:
add "images/date.png" xalign 0.5 yalign 0.0
if sun == True:
$ classroom2 = 'images/classroomday.jpg'
add 'images/sun_icon.jpg' xalign 1.0 yalign 0.0
else:
$ classroom2 = 'images/clasroomnight.jpg'
add 'images/moon_icon.jpg' xalign 1.0 yalign 0.0
text "Monday" xalign 0.5 ypos 20
$ sun = True
$ classroom2 = 'images/classroomday.jpg'
image classroom = '[classroom2]'
label start:
show screen jx
scene classroom2
e "bla bla bla"
e "bla bla bla"
$ sun = False # background is now supposed to turn to night, but it doesn't.
e "It's nighttime."
return
So what I was trying to say was I need the background to also change to night when I set the variable "sun" to False and
that activates the background and my sun icon to change. However, The background doesn't change but the sun icon does. I tried everything I learned from Ren'Py and python and honestly this is my last choice so please any help would be kindly appreciated.
screen jx:
add "images/date.png" xalign 0.5 yalign 0.0
if sun == True:
$ classroom2 = 'images/classroomday.jpg'
add 'images/sun_icon.jpg' xalign 1.0 yalign 0.0
else:
$ classroom2 = 'images/clasroomnight.jpg'
add 'images/moon_icon.jpg' xalign 1.0 yalign 0.0
text "Monday" xalign 0.5 ypos 20
$ sun = True
$ classroom2 = 'images/classroomday.jpg'
image classroom = '[classroom2]'
label start:
show screen jx
scene classroom2
e "bla bla bla"
e "bla bla bla"
$ sun = False # background is now supposed to turn to night, but it doesn't.
e "It's nighttime."
return
So what I was trying to say was I need the background to also change to night when I set the variable "sun" to False and
that activates the background and my sun icon to change. However, The background doesn't change but the sun icon does. I tried everything I learned from Ren'Py and python and honestly this is my last choice so please any help would be kindly appreciated.
default sun = True
layeredimage classroom:
if sun:
'classroomday.jpg'
else:
'clasroomnight.jpg'
screen jx:
add "date.png" xalign 0.5 yalign 0.0
if sun:
add 'sun_icon.jpg' xalign 1.0 yalign 0.0
else:
add 'moon_icon.jpg' xalign 1.0 yalign 0.0
text "Monday" xalign 0.5 ypos 20
label start:
show screen jx
scene classroom
e "bla bla bla"
e "bla bla bla"
$ sun = False # background is now supposed to turn to night.
e "It's nighttime."
return
In my experience, the easiest approach is to use a string value in your variable and interpolate it in the image (thus automatically making it dynamic)
I also do what Remix said as much as possible, making my variable values match something in my file names. Fitted specifically to the OP example, I think it would be fashioned something like...
screen jx:
add "images/date.png" xalign 0.5 yalign 0.0
add "images/[time]_icon.jpg" xalign 1.0 yalign 0.0 # you will need your icons to be day_icon.jpg and night_icon.jpg instead for this to work
text "Monday" xalign 0.5 ypos 20
$ time = "day"
image classroom = "images/classroom[time].jpg"
label start:
show screen jx
scene classroom
e "bla bla bla"
e "bla bla bla"
$ time = "night"
e "It's nighttime."
return