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'm trying to have a randomly selected audio file play while the player is at the main menu. However, for some reason I can't get the random selection to work there. The last option is always selected. Is renpy.random.randint not supposed to work inside options.rpy, or am I just making some daft mistake? The code is as follows:
define executes in init phase. Rest of code you wrote executes during normal script execution.
Your code is equivalent to:
Place all your code inside init block if you want it to execute during init phase.
Ocelot wrote: ↑Thu Jan 27, 2022 5:05 am
define executes in init phase. Rest of code you wrote executes during normal script execution.
Your code is equivalent to:
Place all your code inside init block if you want it to execute during init phase.
Thank you for the answer! Unfortunately I don't know how to do that in practice. What should be written and where to make it work? I tried the following change, but it did not fix the problem. And putting the if - else inside the init block caused an error.
EDIT: Figured out what caused the error, can't have the "define" inside init block. This code works, in case someone else tries to do the same at some point: