- May 29, 2022
- 231
- 432
I feel as if this may be more Python related than Ren'Py related, but I kinda need help right now.
So, I'm making a Sandbox game and I have a time of day system. The player can do certain tasks and such (If it's the morning, the player can make and eat breakfast. But only when it's morning. In the night, the player can get a midnight snack. As long as it's night time.) But I created a screen where it displays the time of day and the day of the week so people know what time it is (Morning time? More like Morbin' time
) but I'm forced to define the variable so it can work (I just defined it as "null" as I assumed that it would work anyway.)
Here's an small, basic excerpt of my code:
And the screen to accommodate it.
Except, when the time changes, it works, but the string doesn't even change! The string still stays as "null". So I want to replace the string instead. I never actually tried to replace strings before, but this is what I think they might do. I'm unsure how it looks in Ren'Py, but I know what it may look like in Python.
Which means hopefully, "It's morning time" will turn into "It's morbin time". I'm trying it in Python and it doesn't seem to work so I'm wondering how I can get it to work.
But, I want to change the ENTIRE instance, instead of a specific word. Like what if I wanted to change "hehehe 69420" to "Touch grass"? How would I do that?
I'm kind of confused on how I can go on doing this. And no, I do not mean CTRL + F, I mean replacing the string itself using str.replace. Sorry if this is a bit long but, HOW?!?!?!
So, I'm making a Sandbox game and I have a time of day system. The player can do certain tasks and such (If it's the morning, the player can make and eat breakfast. But only when it's morning. In the night, the player can get a midnight snack. As long as it's night time.) But I created a screen where it displays the time of day and the day of the week so people know what time it is (Morning time? More like Morbin' time
Here's an small, basic excerpt of my code:
Python:
label timeofday:
while True:
if timeofday == 1:
$ timeofday_string = "Morning"
elif timeofday == 2:
$ timeofday_string = "Evening"
elif timeofday == 3:
$ timeofday_string = "Night"
return
Python:
screen timeofday_display():
text _("[timeofday_string]")
Python:
whattimeisit = "It's morning time"
x = whattimeisit.replace("morning", "morbin")
But, I want to change the ENTIRE instance, instead of a specific word. Like what if I wanted to change "hehehe 69420" to "Touch grass"? How would I do that?
I'm kind of confused on how I can go on doing this. And no, I do not mean CTRL + F, I mean replacing the string itself using str.replace. Sorry if this is a bit long but, HOW?!?!?!