From ebcfa4b78de88343e59095ad28fc4d9f67a91e19 Mon Sep 17 00:00:00 2001 From: Gouvernathor <44340603+Gouvernathor@users.noreply.github.com> Date: Fri, 17 Nov 2023 02:39:35 +0100 Subject: [PATCH] Use hide instead of single-use function --- game/scripts/interface/inventory.rpy | 67 ++++++++++++++-------------- 1 file changed, 33 insertions(+), 34 deletions(-) diff --git a/game/scripts/interface/inventory.rpy b/game/scripts/interface/inventory.rpy index 70014d0a..091961e8 100644 --- a/game/scripts/interface/inventory.rpy +++ b/game/scripts/interface/inventory.rpy @@ -58,39 +58,6 @@ init python: renpy.restart_interaction() - def __init_scope(): - if inventory_mode == 0: - inventory_dict = { - "Gifts": inventory.get_instances_of_type("gift"), - "Books": inventory.get_instances_of_type("book"), - "Scrolls": inventory.get_instances_of_type("scroll"), - "Ingredients": inventory.get_instances_of_type("ingredient"), - "Potions": inventory.get_instances_of_type("potion"), - "Decorations": inventory.get_instances_of_type("decoration"), - "Quest Items": inventory.get_instances_of_type("quest"), - } - elif inventory_mode == 1: - inventory_dict = { - "Gifts": inventory.get_instances_of_type("gift"), - "Potions": inventory.get_instances_of_type("potion"), - "Quest Items": inventory.get_instances_of_type("quest"), - } - - renpy.dynamic( - inventory_dict=inventory_dict, - current_page=0, - current_category="Gifts", - current_filter="Owned", - current_sorting="Available", - ) - - menu_items = inventory_sortfilter(inventory_dict[current_category], current_sorting, current_filter) - renpy.dynamic( - menu_items=menu_items, - menu_items_length=len(menu_items), - current_item=next(iter(menu_items), None), - ) - define items_shown = 36 #################################### @@ -203,7 +170,39 @@ label .give_item(item): label inventory_menu(xx=150, yy=90, inventory_mode=0): # 0 - Inventory, 1 - gifts # Inventory dictionary - $ __init_scope() + python hide: + # hide so that they are not set before being declared dynamic + if inventory_mode == 0: + inventory_dict = { + "Gifts": inventory.get_instances_of_type("gift"), + "Books": inventory.get_instances_of_type("book"), + "Scrolls": inventory.get_instances_of_type("scroll"), + "Ingredients": inventory.get_instances_of_type("ingredient"), + "Potions": inventory.get_instances_of_type("potion"), + "Decorations": inventory.get_instances_of_type("decoration"), + "Quest Items": inventory.get_instances_of_type("quest"), + } + elif inventory_mode == 1: + inventory_dict = { + "Gifts": inventory.get_instances_of_type("gift"), + "Potions": inventory.get_instances_of_type("potion"), + "Quest Items": inventory.get_instances_of_type("quest"), + } + + renpy.dynamic( + inventory_dict=inventory_dict, + current_page=0, + current_category="Gifts", + current_filter="Owned", + current_sorting="Available", + ) + + menu_items = inventory_sortfilter(inventory_dict[current_category], current_sorting, current_filter) + renpy.dynamic( + menu_items=menu_items, + menu_items_length=len(menu_items), + current_item=next(iter(menu_items), None), + ) call screen inventory(xx, yy)