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

(cherry picked from commit 3e86094b0b)
This commit is contained in:
Gouvernathor 2023-11-14 23:16:26 +01:00 committed by LoafyLemon
parent 47b5184e06
commit d48708579b
14 changed files with 186 additions and 186 deletions

View File

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

View File

@ -201,12 +201,12 @@ label achievement_menu(xx=150, yy=90):
label .after_init:
python:
_choice = ui.interact()
renpy.dynamic(__choice = ui.interact())
if _choice[0] == "select":
current_item = _choice[1]
elif _choice[0] == "category":
current_category = _choice[1]
if __choice[0] == "select":
current_item = __choice[1]
elif __choice[0] == "category":
current_category = __choice[1]
if current_category == "All":
category_items = list(persistent.achievements.items())
else:
@ -215,11 +215,11 @@ label achievement_menu(xx=150, yy=90):
menu_items_length = len(menu_items)
current_page = 0
current_item = next(iter(menu_items), None)
elif _choice == "inc":
elif __choice == "inc":
current_page += 1
elif _choice == "dec":
elif __choice == "dec":
current_page += -1
elif _choice == "filter":
elif __choice == "filter":
if current_filter == None:
current_filter = "Locked"
elif current_filter == "Locked":
@ -232,7 +232,7 @@ label achievement_menu(xx=150, yy=90):
menu_items_length = len(menu_items)
current_page = 0
current_item = next(iter(menu_items), None)
elif _choice == "sort":
elif __choice == "sort":
if current_sorting == "A-z":
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)
label .after_init:
$ _choice = ui.interact()
$ renpy.dynamic(__choice = ui.interact())
if _choice == "next":
if __choice == "next":
$ book.next()
play sound "sounds/pageflip.ogg"
show screen book_animator("book_page_next", 0.5)
with d1
elif _choice == "prev":
elif __choice == "prev":
$ book.prev()
play sound "sounds/pageflip.ogg"
show screen book_animator("book_page_prev", 0.5)
with d1
elif _choice == "back":
elif __choice == "back":
$ book.open()
play sound "sounds/pageflipback.ogg"
show screen book_animator("book_page_start", 0.5)
with d1
elif _choice == "Close":
elif __choice == "Close":
$ book.close()
play sound "sounds/bookclose.ogg"
return

View File

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

View File

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

View File

@ -62,13 +62,13 @@ label inventory_menu(xx=150, yy=90):
label .after_init:
$ _choice = ui.interact()
$ renpy.dynamic(__choice = ui.interact())
if _choice[0] == "select":
$ current_item = _choice[1]
elif _choice[0] == "category":
if __choice[0] == "select":
$ current_item = __choice[1]
elif __choice[0] == "category":
python:
current_category = _choice[1]
current_category = __choice[1]
category_items = inventory_dict[current_category]
menu_items = inventory_sortfilter(category_items, current_sorting, current_filter)
menu_items_length = len(menu_items)
@ -79,11 +79,11 @@ label inventory_menu(xx=150, yy=90):
current_page = 0
current_item = next(iter(menu_items), None)
elif _choice == "inc":
elif __choice == "inc":
$ current_page += 1
elif _choice == "dec":
elif __choice == "dec":
$ current_page += -1
elif _choice == "sort":
elif __choice == "sort":
python:
if current_sorting == "A-z":
current_sorting = "z-A"
@ -104,7 +104,7 @@ label inventory_menu(xx=150, yy=90):
if not current_item or not menu_items_length:
current_item = next(iter(menu_items), None)
elif _choice == "filter":
elif __choice == "filter":
python:
if current_filter == None:
current_filter = "Owned"
@ -121,11 +121,11 @@ label inventory_menu(xx=150, yy=90):
if not current_item or not menu_items_length:
current_item = next(iter(menu_items), None)
elif _choice == "use":
elif __choice == "use":
python:
enable_game_menu()
current_item.use()
elif _choice == "give":
elif __choice == "give":
if current_item.type == "gift":
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)
label .after_init:
$ _choice = ui.interact()
$ renpy.dynamic(__choice = ui.interact())
if _choice[0] == "category":
$ current_category = _choice[1]
if __choice[0] == "category":
$ current_category = __choice[1]
$ category_items = stats_dict[current_category]
$ menu_items = stats_sortfilter(category_items, current_sorting)
$ menu_items_length = len(menu_items)
$ current_item = stats_dict[current_category]
#$ current_subcategory = "overview"
elif _choice[0] == "subcat":
if _choice[1] != current_subcategory:
$ current_subcategory = _choice[1]
elif __choice[0] == "subcat":
if __choice[1] != current_subcategory:
$ current_subcategory = __choice[1]
else:
hide screen stats
return

View File

@ -5,34 +5,34 @@ label deck_builder:
label deck_builder_jump:
show screen deck_builder_screen
$ renpy.block_rollback()
$ _choice = ui.interact()
$ renpy.dynamic(__choice = ui.interact())
if _choice in unlocked_cards:
$ selectcard = unlocked_cards.index(_choice)
if __choice in unlocked_cards:
$ selectcard = unlocked_cards.index(__choice)
jump deck_builder_jump
elif _choice == "gallery":
elif __choice == "gallery":
hide screen deck_builder_screen
show screen deck_builder_gallery
elif _choice == "back":
elif __choice == "back":
hide screen deck_builder_gallery
show screen deck_builder_screen
elif _choice == "Close":
elif __choice == "Close":
$ selectcard = -1
hide screen deck_builder_screen
jump main_room_menu
elif _choice == "guide":
elif __choice == "guide":
$ selectcard = -1
hide screen deck_builder_screen
jump deck_builder_guide
elif _choice == "inc":
elif __choice == "inc":
$ currentpage += 1
$ selectcard = -1
jump deck_builder_jump
elif _choice == "dec":
elif __choice == "dec":
$ currentpage -= 1
$ selectcard = -1
jump deck_builder_jump
elif _choice == "unselect":
elif __choice == "unselect":
$ selectcard = -1
jump deck_builder_jump
else:
@ -40,8 +40,8 @@ label deck_builder:
python:
if unlocked_cards[selectcard].copies > -1:
unlocked_cards[selectcard].copies -= 1
add_card_to_deck(playerdeck[int(_choice)].title)
playerdeck[int(_choice)] = unlocked_cards[selectcard]
add_card_to_deck(playerdeck[int(__choice)].title)
playerdeck[int(__choice)] = unlocked_cards[selectcard]
selectcard = -1
pass
jump deck_builder_jump
@ -256,9 +256,9 @@ label deck_builder_guide:
gen "(*Shudders*)" ("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
hide screen deck_builder_tutorial

View File

@ -85,12 +85,12 @@
# $ test_sign.interactive = True
# $ _choice = ui.interact()
# $ renpy.dynamic(__choice = ui.interact())
# if _choice[0] == "result":
# if __choice[0] == "result":
# $ test_sign.interactive = False
# 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!"
# menu:
# "Magician" "Would you like to keep playing?"
@ -116,21 +116,21 @@
# show screen draw_magic
# $ _choice = ui.interact()
# $ renpy.dynamic(__choice = ui.interact())
# if _choice[0] == "result":
# if __choice[0] == "result":
# $ test_sign.interactive = False
# pause 3.0
# if _choice[1] == 0.0:
# if __choice[1] == 0.0:
# "Magician" "You suck."
# elif 25.0 > _choice[1] > 0.0:
# elif 25.0 > __choice[1] > 0.0:
# "Magician" "You still suck."
# elif 50.0 > _choice[1] > 25.0:
# elif 50.0 > __choice[1] > 25.0:
# "Magician" "You're average."
# elif 75.0 > _choice[1] > 50.0:
# elif 75.0 > __choice[1] > 50.0:
# "Magician" "You're above average."
# elif 100.0 > _choice[1] > 75.0:
# elif 100.0 > __choice[1] > 75.0:
# "Magician" "You're good."
# else:
# "Magician" "Holy shit! CRITICAL HIT!"

View File

@ -35,23 +35,23 @@ label mirror_menu(xx=150, yy=90):
show screen mirror(xx, yy)
label .after_init:
$ _choice = ui.interact()
$ renpy.dynamic(__choice = ui.interact())
if _choice[0] == "select":
$ current_item = _choice[1]
if __choice[0] == "select":
$ current_item = __choice[1]
$ current_item.seen = True
elif _choice[0] == "category":
$ current_category = _choice[1]
elif __choice[0] == "category":
$ current_category = __choice[1]
$ menu_items = mirror_sortfilter(mirror.get_instances_of_tag(current_category), current_sorting, current_filter)
$ menu_items_length = len(menu_items)
$ current_page = 0
$ current_item = next(iter(menu_items), None)
elif _choice == "inc":
elif __choice == "inc":
$ current_page += 1
elif _choice == "dec":
elif __choice == "dec":
$ current_page += -1
elif _choice == "filter":
elif __choice == "filter":
if current_filter == "Unlocked":
$ current_filter = None
elif current_filter == None:
@ -61,7 +61,7 @@ label mirror_menu(xx=150, yy=90):
$ menu_items_length = len(menu_items)
$ current_page = 0
$ current_item = next(iter(menu_items), None)
elif _choice == "sort":
elif __choice == "sort":
if current_sorting == "A-z":
$ current_sorting = "z-A"
else:
@ -71,8 +71,8 @@ label mirror_menu(xx=150, yy=90):
$ menu_items_length = len(menu_items)
$ current_page = 0
$ current_item = next(iter(menu_items), None)
elif _choice[0] == "play":
$ _choice[1].play()
elif __choice[0] == "play":
$ __choice[1].play()
$ renpy.jump_out_of_context("mirror")
else:
$ 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:
$ _choice = ui.interact()
$ renpy.dynamic(__choice = ui.interact())
if _choice[0] == "category":
$ current_category = _choice[1]
if __choice[0] == "category":
$ 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)
$ current_item = next(iter(menu_items), None)
elif _choice[0] == "buy":
elif __choice[0] == "buy":
show screen blktone
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")
else:
if len(store_cart) < 5:
$ renpy.call("purchase_outfit", _choice[1])
$ renpy.call("purchase_outfit", __choice[1])
play sound "sounds/money.ogg"
$ game.gold -= _choice[1].price
$ store_cart.add(_choice[1])
$ game.gold -= __choice[1].price
$ 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)
$ current_item = next(iter(menu_items), None)
@ -63,7 +63,7 @@ label shop_dress_menu:
hide screen blktone
with d3
elif _choice == "sort":
elif __choice == "sort":
if current_sorting == "Price (Asc)":
$ 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)
label .after_init:
$ _choice = ui.interact()
$ renpy.dynamix(__choice = ui.interact())
if _choice[0] == "select":
$ current_item = _choice[1]
elif _choice[0] == "category":
$ current_category = _choice[1]
if __choice[0] == "select":
$ current_item = __choice[1]
elif __choice[0] == "category":
$ current_category = __choice[1]
if current_category in {"Gifts", "Ingredients"}:
$ 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"}:
@ -58,18 +58,18 @@ label shop_item_menu(xx=150, yy=90):
$ current_page = 0
$ current_item = next(iter(menu_items), None)
pass
elif _choice == "inc":
elif __choice == "inc":
$ current_page += 1
elif _choice == "dec":
elif __choice == "dec":
$ current_page += -1
elif _choice == "sort":
elif __choice == "sort":
if current_sorting == "Price (Asc)":
$ current_sorting = "Price (Desc)"
elif current_sorting == "Price (Desc)":
$ current_sorting = "Price (Asc)"
$ menu_items = shop_item_sortfilter(category_items, current_sorting)
elif _choice == "buy":
elif __choice == "buy":
$ renpy.call("purchase_item", current_item)
if current_category in {"Gifts", "Ingredients"}:

File diff suppressed because it is too large Load Diff