Conditional Buttons?
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.
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.
Conditional Buttons?
I was wondering if it was possible to have a conditional button in the main menu. So, for instance, if you finish chapter 1, it will remove the "start" button and will replace it with Start Chap. 2 or something similar. Whenever I try using an if statement using a variable named "Chapter2Start" it doesn't allow me to define the variable before the screen loads. How can I fix this? (Can I also make the Chapter 2 Button stay every time you open the game after that?)
Re: Conditional Buttons?
Use a persistent. and default.
Defaults are variables that are defined at the init phase, so they are here before the main menu is staged. anyway, persistent return None if not defined (so, no error anyway) and are preserved between launches.
Add this at the very beginning of your script, out of any label.
default persistent.finished_chapt_1 = False
At the end of chapter 1, use
$ persistent.finished_chapt_1 = True
In the main menu you can check the condition easily.
if persistent.finished_chapt_1:
# the chapter 1 button
else:
# the chapter 2 button
Defaults are variables that are defined at the init phase, so they are here before the main menu is staged. anyway, persistent return None if not defined (so, no error anyway) and are preserved between launches.
Add this at the very beginning of your script, out of any label.
default persistent.finished_chapt_1 = False
At the end of chapter 1, use
$ persistent.finished_chapt_1 = True
In the main menu you can check the condition easily.
if persistent.finished_chapt_1:
# the chapter 1 button
else:
# the chapter 2 button
If you want to debate on a reply I gave to your posts, please QUOTE ME or i'll not be notified about. << now red so probably you'll see it.
10 ? "RENPY"
20 GOTO 10
RUN
10 ? "RENPY"
20 GOTO 10
RUN
Who is online
Users browsing this forum: Google [Bot]