(solved)I want to make the label name a variable
Posted: Wed Jan 03, 2024 4:22 am
I want to make the label name a variable.
It's screens.py
And it's script.py
I expected it.
When you press the GET button on the Ticket001 screen, you are connected to gacha001.
When you press the GET button on the Ticket002 screen, you are connected to gacha002.
But I saw an error.
Could I use the name of the label as a variable?
Please help me.
============
I solved it! thank you!
It's screens.py
Code: Select all
screen menu():
textbutton _("Ticket001") action Show("choice_ticket", character="gacha001")
textbutton _("Ticket002") action Show("choice_ticket", character="gacha002")
screen choice_ticket(character):
zorder 100
textbutton _("GET") action Start("[character!tq]")
Code: Select all
label gacha001:
"get 001!"
return
label gacha002:
"get 002!"
return
When you press the GET button on the Ticket001 screen, you are connected to gacha001.
When you press the GET button on the Ticket002 screen, you are connected to gacha002.
But I saw an error.
Code: Select all
ScriptError: could not find label '[character!tq]'.
Please help me.
============
I solved it! thank you!
Code: Select all
screen choice_ticket(character):
zorder 100
textbutton _("GET") action Start(character)