(solved)I want to make the label name a variable

Discuss how to use the Ren'Py engine to create visual novels and story-based games. New releases are announced in this section.
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.
Post Reply
Message
Author
User avatar
JHeun
Newbie
Posts: 2
Joined: Mon May 15, 2023 8:05 am
Contact:

(solved)I want to make the label name a variable

#1 Post by JHeun »

I want to make the label name a variable.
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]")
And it's script.py

Code: Select all

label gacha001:

    "get 001!"

return

label gacha002:

   "get 002!"

return
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.

Code: Select all

ScriptError: could not find label '[character!tq]'.
Could I use the name of the label as a variable?
Please help me.

============

I solved it! thank you!

Code: Select all

screen choice_ticket(character):

    zorder 100
    textbutton _("GET") action Start(character)

Post Reply

Who is online

Users browsing this forum: Lacha