Unlockable second campaign.
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.
-
NadOtavlas
- Regular
- Posts: 37
- Joined: Sat Apr 21, 2018 3:46 am
- Contact:
Unlockable second campaign.
So in my game I want there to be an unlockable second campaign after getting all of the endings in the game. This campaign is selectable as a on the main menu. I know if I want to program something like this I need to use persistent data but I don't actually know how it works. Can someone explain? Also can someone explain how to change the main menu to include this option?
Re: Unlockable second campaign.
Hi, NadOtavlas,
You need persistent flags for each ending and optionally variable persistent.campaign2_unlocked.
Now when you reach an ending you change the corresponding variable to True and check if all endings are unlocked.
A simple example to add a button to the main menu:
In screens.rpy find screen navigation and add your button there:
However, a better way is to use set to store the flags for endings:
Then you can use len(persistent.endings) to see if all endings are reached: For 2 endings you will have:
You need persistent flags for each ending and optionally variable persistent.campaign2_unlocked.
Code: Select all
default persistent.ending_1 = False
default persistent.ending_2 = False
default persistent.campaign2_unlocked = False
Code: Select all
label ending_1:
...
$ persistent.ending_1 = True
call check_campaign2_unlock
return
label check_campaign2_unlock:
if persistent.ending_1 and persistent.ending_2:
$ persistent.campaign2_unlocked = True
return
In screens.rpy find screen navigation and add your button there:
Code: Select all
screen navigation():
vbox:
...
textbutton _("Preferences") action ShowMenu("preferences")
textbutton _("Campaign 2"):
if persistent.campaign2_unlocked:
action Start('label_campaign2')
Code: Select all
default persistent.endings = set()
label ending_1:
...
$ persistent.endings.add("end_1")
return
Code: Select all
screen navigation():
vbox:
...
textbutton _("Preferences") action ShowMenu("preferences")
textbutton _("Campaign 2"):
if len(persistent.endings) == 2:
action Start('label_campaign2')
Who is online
Users browsing this forum: Bing [Bot], enaielei, Google [Bot]