If you ran this...
it should run fine in a new project by just replacing all of script.rpy with it
just find 6 backgrounds and name them 'bg 0.png' (default) to 'bg 4.png' and 'bg 99.png' (bonus)
As paths unlock, the buttons to choose layout become active.
Once all paths are clear, the bonus becomes available
Anyway...
Code: Select all
default persistent.endings_found = [0] # 0 is our default screen
default possible_endings = range(0, 5) ## start, end minus one - so 1,5 would be 4 endings plus a zero 0 for our default
default persistent.displayed_ending = 0
# then screen menu code along the lines of
screen test_screen():
tag menu
frame:
area (0.0, 0.0, 1.0, 1.0)
background renpy.display.im.Image( "images/bg {0}.png".format(persistent.displayed_ending) )
vbox:
# Some info
text "Showing 'images/bg {0}.png' as background".format(persistent.displayed_ending) xalign 0.5
text "Found {0} from {1} and displaying {2}".format(persistent.endings_found,
possible_endings,
persistent.displayed_ending).replace("[","[[")
# add the select view buttons
#
use buttons_for_menu_choice
# I think if you wanted to do "use sub_menu_variant_x" you might need
# to just test if, elif, else on persistent.displayed_ending and hardcode the "use .... " lines
screen buttons_for_menu_choice():
# some buttons (on the right side) to choose a display to use
vbox:
area (0.8, 0.3, 0.2, 0.4)
for k in possible_endings:
add renpy.display.behavior.TextButton( "{0}".format("Ending {0}".format(k) if k else "Default Ending"),
action=[SetField(persistent, 'displayed_ending', k),
SelectedIf(k == persistent.displayed_ending),
SensitiveIf(k in persistent.endings_found)]
)
add renpy.display.behavior.TextButton( "Bonus Ending",
action=[SetField(persistent, 'displayed_ending', 99),
SelectedIf(99 == persistent.displayed_ending),
SensitiveIf( len(persistent.endings_found) >= len(possible_endings) )]
)
define e = Character("") # hmmm
label start:
# just showing the screen here to test
show screen test_screen
"First Line"
# using buttons to test behaviour
menu:
"Choose an option"
"A choice.":
python:
ending_number = 1 # change number per ending
#
# we have to use test then append as persistence uses revertable list
# which has no .add method.
# Even AddToSet action seems to fail, just more silently
if ending_number not in persistent.endings_found:
persistent.endings_found.append( ending_number )
# using the SetField action here is a no go, so
persistent.displayed_ending = ending_number
# also changed so that the menu shows this route next show
#
renpy.block_rollback()
jump choose_again
"B choice.":
python:
ending_number = 2 # change number per ending
if ending_number not in persistent.endings_found:
persistent.endings_found.append( ending_number )
persistent.displayed_ending = ending_number
renpy.block_rollback()
jump choose_again
"C choice.":
python:
ending_number = 3 # change number per ending
if ending_number not in persistent.endings_found:
persistent.endings_found.append( ending_number )
persistent.displayed_ending = ending_number
renpy.block_rollback()
jump choose_again
"D choice.":
python:
ending_number = 4 # change number per ending
if ending_number not in persistent.endings_found:
persistent.endings_found.append( ending_number )
persistent.displayed_ending = ending_number
renpy.block_rollback()
jump choose_again
"Last Line"
return
label choose_again:
jump start
return
Inline comments added to hopefully make it clearer