# Store the general chapters inside an array for easy manipulation define general_chapters = [ "chapter_1", "chapter_2", "chapter_3", "chapter_4", "chapter_5", "chapter_6", "chapter_7", "chapter_8", "chapter_9", "chapter_10", "chapter_11" ] define ending_routes = { 4: ["chapter_11D", "chapter_12D", "chapter_12_5D", "chapter_13D", "chapter_14D"], 3: ["chapter_11C", "chapter_12C", "chapter_12_5C", "chapter_13C", "chapter_14C"], 2: ["chapter_11B", "chapter_12B", "chapter_13B", "chapter_14B"], 1: ["chapter_11A", "chapter_12A", "chapter_12_5D", "chapter_13A", "chapter_14A"] } default chapters_array_length = len(general_chapters) - 1 default chapter_index = 0 # Index number for the current position of the general chapters array # This stores the name of the label as a string # When starting a new game, it takes the first element of the general_chapters array default current_general_chapter = general_chapters[chapter_index] default ending_route_number = None default is_end_reached = False init -1 python: def ending_image(): #0b0000, DCBA, flash the bits with |=, check with & endings = 0b0000 _e = 0b1 for i in range(1, 5): fn = "e"+str(i)+"of4" endings |= (_e * renpy.seen_image(fn)) _e = _e << 0b1 persistent.old_endings = persistent.endings persistent.endings = endings init python: def next_story_chapter(): global chapter_index global current_general_chapter global ending_route_number global is_end_reached if not is_end_reached and is_end_of_chapters(): ending_route_number = get_ending() add_ending_chapters() is_end_reached = True if chapter_index < chapters_array_length: chapter_index += 1 current_general_chapter = general_chapters[chapter_index] renpy.call(current_general_chapter) else: ending_image() renpy.call("lending") def is_end_of_chapters(): return chapter_index >= chapters_array_length def add_ending_chapters(): global general_chapters global chapters_array_length if ending_route_number in ending_routes: general_chapters.extend(ending_routes[ending_route_number]) chapters_array_length = len(general_chapters) - 1 # renpy.block_rollback() BLOQUEAR O CAMBIARLO A TUPLE general_chapters = tuple(general_chapters)