Dynamic menu choices from array/list [SOLVED]
Posted: Wed Feb 20, 2019 10:21 am
Hello!
I wonder if it's possible to dynamically create menu choices from array in RenPy? Let's say you have 100 skills in the game, and player can use 1-5 of them (like in any rpg). Is it possible to display current skillset as a menu choices and remember the one that player picked? I wrote the following code, obviously it doesn't work:
Edit: correct code is as follow:
I wonder if it's possible to dynamically create menu choices from array in RenPy? Let's say you have 100 skills in the game, and player can use 1-5 of them (like in any rpg). Is it possible to display current skillset as a menu choices and remember the one that player picked? I wrote the following code, obviously it doesn't work:
Code: Select all
python:
menu_items = []
for item in player.skills:
menu_items.append(skillsList[item].name)
choice = menu(menu_items)
for i in Skill.name:
if Skill.name == choice:
chosen_skill = choice
#CalculateDamage(player, enemy, chosen_skill)
Edit: correct code is as follow:
Code: Select all
menu_items = []
for item in player.skills:
menu_items.append(skillsList[item].name)
choice = renpy.display_menu([(skill, skill) for skill in menu_items])