Hi! I'm trying to develop a combat system in which the player will be able to choose different moves to hit and enemy with. I want to make it so that the player chooses an attack and then it creates a submenu on what enemy to attack. I currently have a class containing the objects, aka, the enemies with their different stats and I'm adding those objects to an array. I want to then take that array of enemies and make it so that the submenu is created with the choices being the enemy names, below is the class/array and the menu/submenu. I can't quite get it to work.
init python:
class Enemy:
def __init__ (self, enemyName, enemy_image, hp, atk):
self.name = enemyName
self.image = enemy_image
self.hp = hp
self.atk = atk
thug = Enemy(name="Thug", enemy_image="characters/isuruki.png", hp=100, atk=10)
thief = Enemy(name="Thief", enemy_image="characters/isuruki.png", hp=100, atk=10)
listEnemies = []
listEnemies.append(thug)
listEnemies.append(thief)
menu optionsMenu (screen="optionsChoice"):
"Weak slap":
$ enemyChoices = renpy.display_menu(listEnemies.name.text)
"[enemyChoices]"
"Flail wildly":
call flail_wildly
"Random thing":
text "do something random"
"Random thing 2":
menu optionsAttackMenu (screen="optionsChoice"):
"2nd attack":
call weak_attack
"3rd attack":
call flail_wildly
"4th attack":
text "do something random"
"Back":
call optionsMenu
Submenu based on object array
Forum rules
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
Re: Submenu based on object array
Write a screen on purpose. All your issues will be gone.
Menu are made for standard VNL branching, and quite limited.
Pseudocode:
In your script
now "goon" is a reference to the object you picked. So, goon.name is the name of the enemy you picked.
Menu are made for standard VNL branching, and quite limited.
Pseudocode:
Code: Select all
screen whatever():
vbox:
for x in listEnemies:
$ name = x.name
textbutton "[name]" action Return(x)
Code: Select all
call screen whatever
$ goon = _return
If you want to debate on a reply I gave to your posts, please QUOTE ME or i'll not be notified about. << now red so probably you'll see it.
10 ? "RENPY"
20 GOTO 10
RUN
10 ? "RENPY"
20 GOTO 10
RUN
Who is online
Users browsing this forum: Sirifys-Al