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.
I am writting two labels that Ideally I will use several times during the game with different characters. During part of my game the player will have photoshoots with models and then edit the photos in Photoshop. Seeing as the basic layout of the sections would be the same I would like one function that would be able to read from files to load in not only the script for the interactions (and if I can work out how to do it Menu's) but the images that will be displayed.
I am working on the script part first and failing at the first hurdle. I have written a small pure python script as below and this works fine. However when run inside Renpy (Inside a crappy test script) it cannot open the text file:
label start:
"Welcome to be crappy test game."
init python:
#images\Models\Amy\Scripts Location of text files.
file = open ("images/Models/Amy/txt/sh001.txt")
content = file.readlines()
renpy.say (Amy, content[0])
renpy.say (POV, content[1])
I had the script.py file in my game subfolder and running it it works fine (with print instead of renpy.say)
Should this be possible or am I trying to do something that well cannot be done?
I'm not certain what you're trying to achieve. Like, why do you want to read plain text files? Why not just put that script in labels?
For this case of having a scene that you want to come up multiple times, you can just put it in its own label. And then to decide which kind of photoshoot variant you should play, you could use a series of if statements.
label photoshoot(model):
if model == "Eileen": # have the specific eileen interactions here.
"Hi Eileen. Please, make yourself comfortable."
elif model == "Snake":
"Hi Snake. Looking dashing today."
#etc. I think you get the idea.
label start:
# when it comes time to do the photoshoot with, say, Eileen, you do
call photoshoot("Eileen")
Thanks for this, and yes I can do it that way. However it would make adding new Models in a little more difficult. What I was looking for was a way of making updates a little easier.
I didn't test this, but I assume the problem is that you write "init python:" instead of just "python:"
"init python" tells renpy to initialize this line during startup of the game. Of course if you want to open a file when you start the game, just use init python, but put it outside of the label.
I feel sure you're making your life harder by not letting ren'py help you with managing your dialog, but if you really insist on doing something like this, you can just call renpy ADVCharacters objects as functions, and they will say the dialog. ie, assuming Amy and POV are ADVCharacters, you can do this: