kedta35 wrote: ↑Tue Apr 16, 2024 8:15 pm
I want to add a texting function to a phone I made in Ren'Py.
I don't know how much experience in programming in Python and Renpy you have, but saving messages can be achieved very easily inside a list. Each message on the other hand could be also a list or a tuple, that contains a name, the text and maye a timestamp if that is what you want. But since you want your messages to be images (which I strongly advice against), you can also just save images inside the list. You could also create classes and functions and whatnot, but let's stick to the basics if you're new.
Simple example using two lists to store the message data:
Code: Select all
# messages not yet shown to the player
default messages_queue = [
("Eileen", "Hello, I am Eileen."),
("Eileen", "What's up?")
]
# all messages that have ever been shown
default messages_history = []
I know that a frame should be used for scrolling (...)
No, you have to use a
viewport for that. This is not HTML, frames have different meaning here.
Making the texts go up automatically to make room for new texts when the texts fill the phone screen
A typical method for making auto-scrolling text inside a viewport is using an y-adjustment object:
Code: Select all
screen phone_messages():
default yadj = ui.adjustment()
# make autoscroll possible
if yadj.value == yadj.range:
yadj.value = float('inf')
viewport:
yadjustment yadj
# insert your messages here
for message in messages_history:
text message
For the texts to go up when either an optional text is clicked or the phone screen is clicked.
Just make "yadj" a global variable (in the example it's a screen variable) and set it to
float('inf') whenever you want the text to scroll to the bottom.
Having all the messages can be accessible through an "app" on the phone screen
Create a button that then shows the messages screen using the
Show() function.
Keeping all messages with any characters be viewable at any point by scrolling up and the messages not just being deleted after a scene/event.
Does this mean you want your Renpy dialogue to be the messages you are going to show? Because in that case, it's getting a bit complicated. But it's possible and there are good demos out there. If your game is not only a phone I advice against it, because you would need to alter the say screen.