Fix misuse of variable

- don't use a reserved name (starting with an underscore)
- use a file-local mangled name (starting with two underscores
- use renpy.dynamx to cleanup the variable automatically
This commit is contained in:
Gouvernathor 2023-11-14 23:16:26 +01:00
parent e80bd9e6e6
commit 3e86094b0b
14 changed files with 186 additions and 186 deletions

View File

@ -103,25 +103,25 @@ label upgrades_menu(xx=150, yy=90):
with d3 with d3
label .after_init: label .after_init:
$ _choice = ui.interact() $ renpy.dynamic(__choice = ui.interact())
if _choice[0] == "category": if __choice[0] == "category":
$ current_category = _choice[1] $ current_category = __choice[1]
$ category_items = 0 $ category_items = 0
$ menu_items = upgrades_sortfilter([], current_sorting) $ menu_items = upgrades_sortfilter([], current_sorting)
$ menu_items_length = len(menu_items) $ menu_items_length = len(menu_items)
$ current_item = 0 $ current_item = 0
elif _choice[0] == "subcat": elif __choice[0] == "subcat":
if _choice[1] != current_subcategory: if __choice[1] != current_subcategory:
$ current_subcategory = _choice[1] $ current_subcategory = __choice[1]
elif _choice[0] == "buy": elif __choice[0] == "buy":
if game.gold >= _choice[1] and ton_friendship >= _choice[3]*25: if game.gold >= __choice[1] and ton_friendship >= __choice[3]*25:
python: python:
renpy.play('sounds/money.ogg') renpy.play('sounds/money.ogg')
game.gold -= _choice[1] game.gold -= __choice[1]
_list = _choice[2] _list = __choice[2]
_iter = _choice[3] _iter = __choice[3]
item_bought = True item_bought = True
@ -129,7 +129,7 @@ label upgrades_menu(xx=150, yy=90):
if not _list[i].unlocked: if not _list[i].unlocked:
_list[i].unlock() _list[i].unlock()
ton_clothing_upgrades += 1 ton_clothing_upgrades += 1
elif ton_friendship < _choice[4]: elif ton_friendship < __choice[4]:
$ renpy.play('sounds/fail.ogg') $ renpy.play('sounds/fail.ogg')
"> Tonks doesn't like you enough." "> Tonks doesn't like you enough."
else: else:

View File

@ -201,12 +201,12 @@ label achievement_menu(xx=150, yy=90):
label .after_init: label .after_init:
python: python:
_choice = ui.interact() renpy.dynamic(__choice = ui.interact())
if _choice[0] == "select": if __choice[0] == "select":
current_item = _choice[1] current_item = __choice[1]
elif _choice[0] == "category": elif __choice[0] == "category":
current_category = _choice[1] current_category = __choice[1]
if current_category == "All": if current_category == "All":
category_items = list(persistent.achievements.items()) category_items = list(persistent.achievements.items())
else: else:
@ -215,11 +215,11 @@ label achievement_menu(xx=150, yy=90):
menu_items_length = len(menu_items) menu_items_length = len(menu_items)
current_page = 0 current_page = 0
current_item = next(iter(menu_items), None) current_item = next(iter(menu_items), None)
elif _choice == "inc": elif __choice == "inc":
current_page += 1 current_page += 1
elif _choice == "dec": elif __choice == "dec":
current_page += -1 current_page += -1
elif _choice == "filter": elif __choice == "filter":
if current_filter == None: if current_filter == None:
current_filter = "Locked" current_filter = "Locked"
elif current_filter == "Locked": elif current_filter == "Locked":
@ -232,7 +232,7 @@ label achievement_menu(xx=150, yy=90):
menu_items_length = len(menu_items) menu_items_length = len(menu_items)
current_page = 0 current_page = 0
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":
current_sorting = "z-A" current_sorting = "z-A"
elif current_sorting == "z-A": elif current_sorting == "z-A":

View File

@ -79,24 +79,24 @@ label book_handle(book=None):
show screen book_animator("book_page_next", 0.5) show screen book_animator("book_page_next", 0.5)
label .after_init: label .after_init:
$ _choice = ui.interact() $ renpy.dynamic(__choice = ui.interact())
if _choice == "next": if __choice == "next":
$ book.next() $ book.next()
play sound "sounds/pageflip.ogg" play sound "sounds/pageflip.ogg"
show screen book_animator("book_page_next", 0.5) show screen book_animator("book_page_next", 0.5)
with d1 with d1
elif _choice == "prev": elif __choice == "prev":
$ book.prev() $ book.prev()
play sound "sounds/pageflip.ogg" play sound "sounds/pageflip.ogg"
show screen book_animator("book_page_prev", 0.5) show screen book_animator("book_page_prev", 0.5)
with d1 with d1
elif _choice == "back": elif __choice == "back":
$ book.open() $ book.open()
play sound "sounds/pageflipback.ogg" play sound "sounds/pageflipback.ogg"
show screen book_animator("book_page_start", 0.5) show screen book_animator("book_page_start", 0.5)
with d1 with d1
elif _choice == "Close": elif __choice == "Close":
$ book.close() $ book.close()
play sound "sounds/bookclose.ogg" play sound "sounds/bookclose.ogg"
return return

View File

@ -31,11 +31,11 @@ label brewing_menu(xx=150, yy=90):
show screen brewing(xx, yy) show screen brewing(xx, yy)
label .after_init: label .after_init:
$ _choice = ui.interact() $ renpy.dynamic(__choice = ui.interact())
if _choice[0] == "select": if __choice[0] == "select":
$ current_item = _choice[1] $ current_item = __choice[1]
elif _choice == "filter": elif __choice == "filter":
if current_filter == "Unlocked": if current_filter == "Unlocked":
$ current_filter = None $ current_filter = None
elif current_filter == None: elif current_filter == None:
@ -44,7 +44,7 @@ label brewing_menu(xx=150, yy=90):
$ 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) $ 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":
$ current_sorting = "z-A" $ current_sorting = "z-A"
else: else:
@ -53,10 +53,10 @@ label brewing_menu(xx=150, yy=90):
$ 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) $ 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():
play sound "sounds/bubble.ogg" play sound "sounds/bubble.ogg"
$ _choice[1].make() $ __choice[1].make()
else: else:
gen "It appears I'm missing some key ingredients..." ("base", xpos="far_left", ypos="head") gen "It appears I'm missing some key ingredients..." ("base", xpos="far_left", ypos="head")
else: else:

View File

@ -34,18 +34,18 @@ label summon_menu(xx=723, yy=90):
show screen summon(xx, yy) show screen summon(xx, yy)
$ _choice = ui.interact() $ renpy.dynamic(__choice = ui.interact())
if _choice[0] == "summon": if __choice[0] == "summon":
hide screen summon hide screen summon
if not _choice[2]: if not __choice[2]:
$ enable_game_menu() $ enable_game_menu()
$ renpy.jump_out_of_context("summon_"+_choice[1].lower()) $ renpy.jump_out_of_context("summon_"+__choice[1].lower())
else: else:
if game.daytime or _choice[1] in ["Tonks", "Snape"]: if game.daytime or __choice[1] in ["Tonks", "Snape"]:
nar "[_choice[1]] is currently busy. Try again later." nar "[__choice[1]] is currently busy. Try again later."
else: else:
nar "[_choice[1]] is currently asleep. Try again tomorrow." nar "[__choice[1]] is currently asleep. Try again tomorrow."
else: else:
hide screen summon hide screen summon
return return

View File

@ -62,13 +62,13 @@ label inventory_menu(xx=150, yy=90):
label .after_init: label .after_init:
$ _choice = ui.interact() $ renpy.dynamic(__choice = ui.interact())
if _choice[0] == "select": if __choice[0] == "select":
$ current_item = _choice[1] $ current_item = __choice[1]
elif _choice[0] == "category": elif __choice[0] == "category":
python: python:
current_category = _choice[1] current_category = __choice[1]
category_items = inventory_dict[current_category] category_items = inventory_dict[current_category]
menu_items = inventory_sortfilter(category_items, current_sorting, current_filter) menu_items = inventory_sortfilter(category_items, current_sorting, current_filter)
menu_items_length = len(menu_items) menu_items_length = len(menu_items)
@ -79,11 +79,11 @@ label inventory_menu(xx=150, yy=90):
current_page = 0 current_page = 0
current_item = next(iter(menu_items), None) current_item = next(iter(menu_items), None)
elif _choice == "inc": elif __choice == "inc":
$ current_page += 1 $ current_page += 1
elif _choice == "dec": elif __choice == "dec":
$ current_page += -1 $ current_page += -1
elif _choice == "sort": elif __choice == "sort":
python: python:
if current_sorting == "A-z": if current_sorting == "A-z":
current_sorting = "z-A" current_sorting = "z-A"
@ -104,7 +104,7 @@ label inventory_menu(xx=150, yy=90):
if not current_item or not menu_items_length: if not current_item or not menu_items_length:
current_item = next(iter(menu_items), None) current_item = next(iter(menu_items), None)
elif _choice == "filter": elif __choice == "filter":
python: python:
if current_filter == None: if current_filter == None:
current_filter = "Owned" current_filter = "Owned"
@ -121,11 +121,11 @@ label inventory_menu(xx=150, yy=90):
if not current_item or not menu_items_length: if not current_item or not menu_items_length:
current_item = next(iter(menu_items), None) current_item = next(iter(menu_items), None)
elif _choice == "use": elif __choice == "use":
python: python:
enable_game_menu() enable_game_menu()
current_item.use() current_item.use()
elif _choice == "give": elif __choice == "give":
if current_item.type == "gift": if current_item.type == "gift":
if get_character_gifted(states.active_girl): if get_character_gifted(states.active_girl):

View File

@ -111,18 +111,18 @@ label stats_menu(xx=150, yy=90):
show screen stats(xx, yy) show screen stats(xx, yy)
label .after_init: label .after_init:
$ _choice = ui.interact() $ renpy.dynamic(__choice = ui.interact())
if _choice[0] == "category": if __choice[0] == "category":
$ current_category = _choice[1] $ current_category = __choice[1]
$ category_items = stats_dict[current_category] $ category_items = stats_dict[current_category]
$ menu_items = stats_sortfilter(category_items, current_sorting) $ menu_items = stats_sortfilter(category_items, current_sorting)
$ menu_items_length = len(menu_items) $ menu_items_length = len(menu_items)
$ current_item = stats_dict[current_category] $ current_item = stats_dict[current_category]
#$ current_subcategory = "overview" #$ current_subcategory = "overview"
elif _choice[0] == "subcat": elif __choice[0] == "subcat":
if _choice[1] != current_subcategory: if __choice[1] != current_subcategory:
$ current_subcategory = _choice[1] $ current_subcategory = __choice[1]
else: else:
hide screen stats hide screen stats
return return

View File

@ -5,34 +5,34 @@ label deck_builder:
label deck_builder_jump: label deck_builder_jump:
show screen deck_builder_screen show screen deck_builder_screen
$ renpy.block_rollback() $ renpy.block_rollback()
$ _choice = ui.interact() $ renpy.dynamic(__choice = ui.interact())
if _choice in unlocked_cards: if __choice in unlocked_cards:
$ selectcard = unlocked_cards.index(_choice) $ selectcard = unlocked_cards.index(__choice)
jump deck_builder_jump jump deck_builder_jump
elif _choice == "gallery": elif __choice == "gallery":
hide screen deck_builder_screen hide screen deck_builder_screen
show screen deck_builder_gallery show screen deck_builder_gallery
elif _choice == "back": elif __choice == "back":
hide screen deck_builder_gallery hide screen deck_builder_gallery
show screen deck_builder_screen show screen deck_builder_screen
elif _choice == "Close": elif __choice == "Close":
$ selectcard = -1 $ selectcard = -1
hide screen deck_builder_screen hide screen deck_builder_screen
jump main_room_menu jump main_room_menu
elif _choice == "guide": elif __choice == "guide":
$ selectcard = -1 $ selectcard = -1
hide screen deck_builder_screen hide screen deck_builder_screen
jump deck_builder_guide jump deck_builder_guide
elif _choice == "inc": elif __choice == "inc":
$ currentpage += 1 $ currentpage += 1
$ selectcard = -1 $ selectcard = -1
jump deck_builder_jump jump deck_builder_jump
elif _choice == "dec": elif __choice == "dec":
$ currentpage -= 1 $ currentpage -= 1
$ selectcard = -1 $ selectcard = -1
jump deck_builder_jump jump deck_builder_jump
elif _choice == "unselect": elif __choice == "unselect":
$ selectcard = -1 $ selectcard = -1
jump deck_builder_jump jump deck_builder_jump
else: else:
@ -40,8 +40,8 @@ label deck_builder:
python: python:
if unlocked_cards[selectcard].copies > -1: if unlocked_cards[selectcard].copies > -1:
unlocked_cards[selectcard].copies -= 1 unlocked_cards[selectcard].copies -= 1
add_card_to_deck(playerdeck[int(_choice)].title) add_card_to_deck(playerdeck[int(__choice)].title)
playerdeck[int(_choice)] = unlocked_cards[selectcard] playerdeck[int(__choice)] = unlocked_cards[selectcard]
selectcard = -1 selectcard = -1
pass pass
jump deck_builder_jump jump deck_builder_jump
@ -256,9 +256,9 @@ label deck_builder_guide:
gen "(*Shudders*)" ("base", xpos="far_left", ypos="head") gen "(*Shudders*)" ("base", xpos="far_left", ypos="head")
gen "(Well... might as well...)" ("base", xpos="far_left", ypos="head") gen "(Well... might as well...)" ("base", xpos="far_left", ypos="head")
#$ _choice = ui.interact() #$ renpy.dynamic(__choice = ui.interact())
#if _choice == "back": #if __choice == "back":
call music_block call music_block
hide screen deck_builder_tutorial hide screen deck_builder_tutorial

View File

@ -85,12 +85,12 @@
# $ test_sign.interactive = True # $ test_sign.interactive = True
# $ _choice = ui.interact() # $ renpy.dynamic(__choice = ui.interact())
# if _choice[0] == "result": # if __choice[0] == "result":
# $ test_sign.interactive = False # $ test_sign.interactive = False
# pause 3.0 # pause 3.0
# if _choice[1] >= 50.0: # if __choice[1] >= 50.0:
# "Magician" "Congratulations, you have passed the test with the score of [_sign_max]%%, I am proud of you!" # "Magician" "Congratulations, you have passed the test with the score of [_sign_max]%%, I am proud of you!"
# menu: # menu:
# "Magician" "Would you like to keep playing?" # "Magician" "Would you like to keep playing?"
@ -116,21 +116,21 @@
# show screen draw_magic # show screen draw_magic
# $ _choice = ui.interact() # $ renpy.dynamic(__choice = ui.interact())
# if _choice[0] == "result": # if __choice[0] == "result":
# $ test_sign.interactive = False # $ test_sign.interactive = False
# pause 3.0 # pause 3.0
# if _choice[1] == 0.0: # if __choice[1] == 0.0:
# "Magician" "You suck." # "Magician" "You suck."
# elif 25.0 > _choice[1] > 0.0: # elif 25.0 > __choice[1] > 0.0:
# "Magician" "You still suck." # "Magician" "You still suck."
# elif 50.0 > _choice[1] > 25.0: # elif 50.0 > __choice[1] > 25.0:
# "Magician" "You're average." # "Magician" "You're average."
# elif 75.0 > _choice[1] > 50.0: # elif 75.0 > __choice[1] > 50.0:
# "Magician" "You're above average." # "Magician" "You're above average."
# elif 100.0 > _choice[1] > 75.0: # elif 100.0 > __choice[1] > 75.0:
# "Magician" "You're good." # "Magician" "You're good."
# else: # else:
# "Magician" "Holy shit! CRITICAL HIT!" # "Magician" "Holy shit! CRITICAL HIT!"

View File

@ -35,23 +35,23 @@ label mirror_menu(xx=150, yy=90):
show screen mirror(xx, yy) show screen mirror(xx, yy)
label .after_init: label .after_init:
$ _choice = ui.interact() $ renpy.dynamic(__choice = ui.interact())
if _choice[0] == "select": if __choice[0] == "select":
$ current_item = _choice[1] $ current_item = __choice[1]
$ current_item.seen = True $ current_item.seen = True
elif _choice[0] == "category": elif __choice[0] == "category":
$ current_category = _choice[1] $ current_category = __choice[1]
$ menu_items = mirror_sortfilter(mirror.get_instances_of_tag(current_category), current_sorting, current_filter) $ menu_items = mirror_sortfilter(mirror.get_instances_of_tag(current_category), current_sorting, current_filter)
$ menu_items_length = len(menu_items) $ menu_items_length = len(menu_items)
$ current_page = 0 $ current_page = 0
$ current_item = next(iter(menu_items), None) $ current_item = next(iter(menu_items), None)
elif _choice == "inc": elif __choice == "inc":
$ current_page += 1 $ current_page += 1
elif _choice == "dec": elif __choice == "dec":
$ current_page += -1 $ current_page += -1
elif _choice == "filter": elif __choice == "filter":
if current_filter == "Unlocked": if current_filter == "Unlocked":
$ current_filter = None $ current_filter = None
elif current_filter == None: elif current_filter == None:
@ -61,7 +61,7 @@ label mirror_menu(xx=150, yy=90):
$ menu_items_length = len(menu_items) $ menu_items_length = len(menu_items)
$ current_page = 0 $ current_page = 0
$ 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":
$ current_sorting = "z-A" $ current_sorting = "z-A"
else: else:
@ -71,8 +71,8 @@ label mirror_menu(xx=150, yy=90):
$ menu_items_length = len(menu_items) $ menu_items_length = len(menu_items)
$ current_page = 0 $ current_page = 0
$ current_item = next(iter(menu_items), None) $ current_item = next(iter(menu_items), None)
elif _choice[0] == "play": elif __choice[0] == "play":
$ _choice[1].play() $ __choice[1].play()
$ renpy.jump_out_of_context("mirror") $ renpy.jump_out_of_context("mirror")
else: else:
$ enable_game_menu() $ enable_game_menu()

File diff suppressed because it is too large Load Diff

View File

@ -33,24 +33,24 @@ label shop_dress_menu:
label .after_init: label .after_init:
$ _choice = ui.interact() $ renpy.dynamic(__choice = ui.interact())
if _choice[0] == "category": if __choice[0] == "category":
$ current_category = _choice[1] $ current_category = __choice[1]
$ menu_items = shop_dress_sortfilter((x for x in category_items.get(current_category, []) if (x.unlocked == False and x.price > 0 and x not in store_cart)), current_sorting) $ menu_items = shop_dress_sortfilter((x for x in category_items.get(current_category, []) if (x.unlocked == False and x.price > 0 and x not in store_cart)), current_sorting)
$ current_item = next(iter(menu_items), None) $ current_item = next(iter(menu_items), None)
elif _choice[0] == "buy": elif __choice[0] == "buy":
show screen blktone show screen blktone
with d3 with d3
if game.gold < _choice[1].price: if game.gold < __choice[1].price:
gen "(I don't have enough gold.)" ("base", xpos="far_left", ypos="head") gen "(I don't have enough gold.)" ("base", xpos="far_left", ypos="head")
else: else:
if len(store_cart) < 5: if len(store_cart) < 5:
$ renpy.call("purchase_outfit", _choice[1]) $ renpy.call("purchase_outfit", __choice[1])
play sound "sounds/money.ogg" play sound "sounds/money.ogg"
$ game.gold -= _choice[1].price $ game.gold -= __choice[1].price
$ store_cart.add(_choice[1]) $ store_cart.add(__choice[1])
$ menu_items = shop_dress_sortfilter((x for x in category_items.get(current_category, []) if (x.unlocked == False and x.price > 0 and x not in store_cart)), current_sorting) $ menu_items = shop_dress_sortfilter((x for x in category_items.get(current_category, []) if (x.unlocked == False and x.price > 0 and x not in store_cart)), current_sorting)
$ current_item = next(iter(menu_items), None) $ current_item = next(iter(menu_items), None)
@ -63,7 +63,7 @@ label shop_dress_menu:
hide screen blktone hide screen blktone
with d3 with d3
elif _choice == "sort": elif __choice == "sort":
if current_sorting == "Price (Asc)": if current_sorting == "Price (Asc)":
$ current_sorting = "Price (Desc)" $ current_sorting = "Price (Desc)"
elif current_sorting == "Price (Desc)": elif current_sorting == "Price (Desc)":

View File

@ -43,12 +43,12 @@ label shop_item_menu(xx=150, yy=90):
show screen shop_item(xx, yy) show screen shop_item(xx, yy)
label .after_init: label .after_init:
$ _choice = ui.interact() $ renpy.dynamix(__choice = ui.interact())
if _choice[0] == "select": if __choice[0] == "select":
$ current_item = _choice[1] $ current_item = __choice[1]
elif _choice[0] == "category": elif __choice[0] == "category":
$ current_category = _choice[1] $ current_category = __choice[1]
if current_category in {"Gifts", "Ingredients"}: if current_category in {"Gifts", "Ingredients"}:
$ category_items = [x for x in inventory_dict[current_category] if bool(x.price > 0 and x.unlocked)] $ category_items = [x for x in inventory_dict[current_category] if bool(x.price > 0 and x.unlocked)]
elif current_category in {"Books", "Scrolls", "Decorations", "Quest Items"}: elif current_category in {"Books", "Scrolls", "Decorations", "Quest Items"}:
@ -58,18 +58,18 @@ label shop_item_menu(xx=150, yy=90):
$ current_page = 0 $ current_page = 0
$ current_item = next(iter(menu_items), None) $ current_item = next(iter(menu_items), None)
pass pass
elif _choice == "inc": elif __choice == "inc":
$ current_page += 1 $ current_page += 1
elif _choice == "dec": elif __choice == "dec":
$ current_page += -1 $ current_page += -1
elif _choice == "sort": elif __choice == "sort":
if current_sorting == "Price (Asc)": if current_sorting == "Price (Asc)":
$ current_sorting = "Price (Desc)" $ current_sorting = "Price (Desc)"
elif current_sorting == "Price (Desc)": elif current_sorting == "Price (Desc)":
$ current_sorting = "Price (Asc)" $ current_sorting = "Price (Asc)"
$ menu_items = shop_item_sortfilter(category_items, current_sorting) $ menu_items = shop_item_sortfilter(category_items, current_sorting)
elif _choice == "buy": elif __choice == "buy":
$ renpy.call("purchase_item", current_item) $ renpy.call("purchase_item", current_item)
if current_category in {"Gifts", "Ingredients"}: if current_category in {"Gifts", "Ingredients"}:

File diff suppressed because it is too large Load Diff