Hello, I am trying to use choice panels with Python, but, even if following the instructions, nothing seems to work (simply, the panel won’t show up). Anyone could help on this?
Hi there, in the Basics Python 2 you can find all three GUI.hud panels (info, choice and the quiz panel). The choice panel is a bit tricky in Python (on_answer still doesn’t work properly, or I couldn’t figure it out how it works), the rest works fine.
It would be great if someone could help with this piece of code.
Thank you very much. In fact, in the sample I found only the info panel (which anyway let me understand how to use both three). As you said, however, how to make work the on_answer for the choice panel remains unsolved: the API documentation is very poor, and comparing it with Typescript documentation didn’t help neither.
I managed to make the code do an action with this code
GUI.hud.show_choice_panel(question=“boo?”, answer1=“baah”, answer2=“beee”,on_answer=prova(1))
where the function “prova” does something.
But, (1), the action coded by prova begins as the panel shows up and not after the choice is made, and (2) it’s impossibile to distinguish between answer1 and answer2.
Playing around, and with an help from Microsoft Edge AI, I managed to make the choice panel work: check this code:
def choicepanel():
GUI.hud.show_choice_panel(question=“boo?”, answer1=“baah”, answer2=“beee”,on_answer=prova)
with the function prova definend as:
def prova(k):
if k == 1:
pers03.speech = “opz1”
elif k == 2:
pers03.speech = “opz22”
Thank You Very Much!
Finally, everything’s working now in Basics python 2.