Sort inplace and skip unused variable

This commit is contained in:
Gouvernathor 2023-11-17 04:05:49 +01:00
parent f6c0054be0
commit e84d5cbdf0

View File

@ -9,7 +9,7 @@ init python:
item = sorted(item, key=lambda x: natsort_key(x.name)) item = sorted(item, key=lambda x: natsort_key(x.name))
if sortby == "z-A": if sortby == "z-A":
item = sorted(item, key=lambda x: natsort_key(x.name), reverse=True) item.sort(key=lambda x: natsort_key(x.name), reverse=True)
return item return item
@ -25,7 +25,6 @@ label brewing_menu(xx=150, yy=90):
current_sorting = "A-z" current_sorting = "A-z"
menu_items = brewing_sortfilter(inventory.get_instances_of_type("potion"), current_sorting, current_filter) menu_items = brewing_sortfilter(inventory.get_instances_of_type("potion"), current_sorting, current_filter)
menu_items_length = len(menu_items)
current_item = next(iter(menu_items), None) current_item = next(iter(menu_items), None)
show screen brewing(xx, yy) show screen brewing(xx, yy)
@ -42,7 +41,6 @@ label brewing_menu(xx=150, yy=90):
$ current_filter = "Unlocked" $ current_filter = "Unlocked"
$ menu_items = brewing_sortfilter(inventory.get_instances_of_type("potion"), current_sorting, current_filter) $ menu_items = brewing_sortfilter(inventory.get_instances_of_type("potion"), current_sorting, current_filter)
$ menu_items_length = len(menu_items)
$ current_item = next(iter(menu_items), None) $ current_item = next(iter(menu_items), None)
elif __choice == "sort": elif __choice == "sort":
if current_sorting == "A-z": if current_sorting == "A-z":
@ -51,7 +49,6 @@ label brewing_menu(xx=150, yy=90):
$ current_sorting = "A-z" $ current_sorting = "A-z"
$ menu_items = brewing_sortfilter(inventory.get_instances_of_type("potion"), current_sorting, current_filter) $ menu_items = brewing_sortfilter(inventory.get_instances_of_type("potion"), current_sorting, current_filter)
$ menu_items_length = len(menu_items)
#$ current_item = next(iter(menu_items), None) #$ current_item = next(iter(menu_items), None)
elif __choice[0] == "make": elif __choice[0] == "make":
if __choice[1].has_ingredients(): if __choice[1].has_ingredients():