How to make a textbutton action make appear a text somewhere?

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
jacob_ax
Regular
Posts: 32
Joined: Thu Jan 31, 2019 9:21 am
Contact:

How to make a textbutton action make appear a text somewhere?

#1 Post by jacob_ax »

Hi guys!
I'm trying to make a quest diary, but the problem I'm having is that I'd like to show some text (taken from a dictionary) inside a frame when I click on a textbutton. Here is an image that shows what I'd like to do:

Capture.PNG
(8.75 KiB) Not downloaded yet


And here is the code:

Code: Select all

screen quest_screen:
    frame:
        xpos 150
        ypos 100
        hbox:
            frame:
                vbox:
                    textbutton "Quest 1" action [take the quest 1 text from a dictionary and show inside the frame below]
                    textbutton "Quest 2" action [take the quest 2 text from a dictionary and show inside the frame below]
            frame:
                text"Suppose clicked on Quest 1, here should appear a description of the quest."


What is the action I should use? Is there a different approach to solve this problem? I suspect that it's much more complicated than I think :P
Thanks :)

User avatar
trooper6
Lemma-Class Veteran
Posts: 3712
Joined: Sat Jul 09, 2011 10:33 pm
Projects: A Close Shave
Location: Medford, MA
Contact:

Re: How to make a textbutton action make appear a text somewhere?

#2 Post by trooper6 »

Make a new project with this code to test it out.

Code: Select all

default quest_dict = {"q1":"This is the description of Quest 1",
"q2":"This is the description of Quest 2"}

screen quest_screen():
    default quest_text = None
    frame:
        xpos 150
        ypos 100
        hbox:
            frame:
                vbox:
                    textbutton "Quest 1" action SetScreenVariable("quest_text", quest_dict["q1"])
                    textbutton "Quest 2" action SetScreenVariable("quest_text", quest_dict["q2"])
            frame:
                text"[quest_text]"

label start:

    "Test Start"
    show screen quest_screen()
    "End Test"
    "Game Over"
    return
A Close Shave:
*Last Thing Done (Aug 17): Finished coding emotions and camera for 4/10 main labels.
*Currently Doing: Coding of emotions and camera for the labels--On 5/10
*First Next thing to do: Code in all CG and special animation stuff
*Next Next thing to do: Set up film animation
*Other Thing to Do: Do SFX and Score (maybe think about eye blinks?)
Check out My Clock Cookbook Recipe: http://lemmasoft.renai.us/forums/viewto ... 51&t=21978

jacob_ax
Regular
Posts: 32
Joined: Thu Jan 31, 2019 9:21 am
Contact:

Re: How to make a textbutton action make appear a text somewhere?

#3 Post by jacob_ax »

trooper6 wrote: Mon Feb 18, 2019 4:31 pm Make a new project with this code to test it out.

Code: Select all

default quest_dict = {"q1":"This is the description of Quest 1",
"q2":"This is the description of Quest 2"}

screen quest_screen():
    default quest_text = None
    frame:
        xpos 150
        ypos 100
        hbox:
            frame:
                vbox:
                    textbutton "Quest 1" action SetScreenVariable("quest_text", quest_dict["q1"])
                    textbutton "Quest 2" action SetScreenVariable("quest_text", quest_dict["q2"])
            frame:
                text"[quest_text]"

label start:

    "Test Start"
    show screen quest_screen()
    "End Test"
    "Game Over"
    return
Thank you very very much trooper6, it works wonderfully :)

Post Reply

Who is online

Users browsing this forum: Google [Bot]