forked from Cavemanon/SnootGame
Add setup_ending. Endings are now determined and setup the moment branching is required.
This commit is contained in:
@@ -24,4 +24,5 @@ default chapter_list_index = 0 # Index number for the current position of the ch
|
||||
default current_chapter = chapter_list[chapter_list_index] # Store the name of the label as a string
|
||||
|
||||
# What ending we're on
|
||||
default ending_route_number = None # A value of None signals to get_ending() to determine the value based off anon/fang scores when it is called
|
||||
default ending_route_number = None # A value of None signals to get_ending() to determine the value based off anon/fang scores when it is called
|
||||
default ending_chapters_determined = False
|
@@ -13,25 +13,17 @@ init -1 python:
|
||||
|
||||
init python:
|
||||
def next_story_chapter():
|
||||
global chapter_list_index, current_chapter, chapter_list, ending_route_number, is_end_reached, chapter_list_length
|
||||
global chapter_list_index, current_chapter, chapter_list, ending_route_number, chapter_list_length, ending_chapters_determined
|
||||
|
||||
# Add check "is_end_reached" to have this if statement be executed only once when finishing the general chapters
|
||||
if not is_end_reached and chapter_list_index >= chapter_list_length:
|
||||
# Add ending chapters
|
||||
ending_route_number = get_ending()
|
||||
if route_number in ending_routes:
|
||||
chapter_list.extend(ending_routes[ending_route_number])
|
||||
|
||||
# Updates variables for newly extended 'chapter_list' with ending chapters
|
||||
chapter_list_length = len(chapter_list) - 1 # chapter_list_length is updated to reflect the addition to the chapter_list array
|
||||
is_end_reached = True
|
||||
|
||||
|
||||
if chapter_list_index < chapter_list_length:
|
||||
chapter_list_index += 1
|
||||
current_chapter = chapter_list[chapter_list_index]
|
||||
renpy.call(current_chapter)
|
||||
|
||||
# Safeguard if setup_ending wasn't called somehow
|
||||
elif not ending_chapters_determined:
|
||||
setup_ending(get_ending())
|
||||
|
||||
# We're at an ending
|
||||
else:
|
||||
ending_image()
|
||||
@@ -40,3 +32,14 @@ init python:
|
||||
renpy.quit()
|
||||
else:
|
||||
renpy.call("lending")
|
||||
|
||||
def setup_ending(ending):
|
||||
global ending_route_number, chapter_list, chapter_list_length, ending_chapters_determined
|
||||
|
||||
ending_route_number = ending
|
||||
|
||||
# Add ending chapters
|
||||
chapter_list.extend(ending_routes[ending_route_number])
|
||||
chapter_list_length = len(chapter_list) - 1 # chapter_list_length is updated to reflect the addition to the chapter_list array
|
||||
|
||||
ending_chapters_determined = True
|
Reference in New Issue
Block a user