Say something from a screen

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
Amethysts
Regular
Posts: 41
Joined: Thu Aug 23, 2018 1:17 pm
Projects: Coalescence
Skype: amethysts-studio
itch: amethysts
Contact:

Say something from a screen

#1 Post by Amethysts »

Hello! does anyone know how to write a dialog line from a screen (via an action for example)?

I'd like to display a summary of the choice the player has just made!

I'd like to do something like

Code: Select all

button:
  text i.caption
  action [i.action, Function(renpy.say(choix_resume, i.caption)]
where choix_resume is a Character that I have defined, but that doesn't work.

The Function action must return a callable action and I've read in the doc that one shouldn't do some python within a screen if this affects the game...

Can someone help me ? Thanks !

User avatar
Alex
Lemma-Class Veteran
Posts: 3094
Joined: Fri Dec 11, 2009 5:25 pm
Contact:

Re: Say something from a screen

#2 Post by Alex »

You could try to make a label with this say statement and pass character and text to it by clicking button of your screen.
Something like

Code: Select all

label some_say_label(char, txt):
    $ renpy.say(char, txt)
    return

Code: Select all

button:
  text i.caption
  action [i.action, Call('some_say_label', choix_resume, i.caption, from_current=True)]
https://www.renpy.org/doc/html/screen_actions.html#Call

User avatar
Amethysts
Regular
Posts: 41
Joined: Thu Aug 23, 2018 1:17 pm
Projects: Coalescence
Skype: amethysts-studio
itch: amethysts
Contact:

Re: Say something from a screen

#3 Post by Amethysts »

Okay ! I've already used this trick in my project but I didn't know if this was a "clean" way (good practice) to solve this issue.

Thank you !

User avatar
Amethysts
Regular
Posts: 41
Joined: Thu Aug 23, 2018 1:17 pm
Projects: Coalescence
Skype: amethysts-studio
itch: amethysts
Contact:

Re: Say something from a screen

#4 Post by Amethysts »

So I tried and this doesn't work, or not correctly because it breaks something else. No matter what choice I select, the sentence is said by my character but after it behaves like it is the last choice that have been chosen !

Image
Image

I've tried with and without `from current`. With from current, a bug happens : the choice keeps repeating.

Image

I've tried reversing the i.action and the Call too, without success.

I think the problem is here:

Code: Select all

            for i in items:
                button:
                    style "coal_choice_button"
                    text i.caption style "coal_nvl_caption"
                    action [i.action, Call('say_after_choice', i.caption), SetVariable("quick_menu", True)] ####### HERE
                if "default" in i.args:
                    timer 0.02 repeat True action [If(countdown_time > 0,
                                                    true=[SetVariable('countdown_time', countdown_time-0.02), SetVariable("quick_menu", False)],
                                                    false=[i.action, Call('say_after_choice', i.caption), SetVariable("quick_menu", True)])]
                    
                    bar value countdown_time range countdown_range style "coal_countdown_bar"
                        

    add SideImage() xalign 0.0 yalign 1.0

label say_after_choice(txt=last_choice):
    $ renpy.say(after_choice, txt)
    $ renpy.fix_rollback() #TODO might not be a great idea
    return

I know it isn't perfect but I tried to make it as readable as possible.

Here is the full screen code:

Code: Select all

screen nvl(dialogue, items=None):

    window:
        style "nvl_window"

        has vbox:
            spacing gui.nvl_spacing

        ## Displays dialogue in either a vpgrid or the vbox.
        if gui.nvl_height:

            vpgrid:
                cols 1
                yinitial 1.0

                use nvl_dialogue(dialogue)

        else:

            use nvl_dialogue(dialogue)

        ## Displays the menu, if given. The menu may be displayed incorrectly if
        ## config.narrator_menu is set to True, as it is above.
        vbox:
            spacing 10
            for i in items:
                button:
                    style "coal_choice_button"
                    text i.caption style "coal_nvl_caption"
                    action [i.action, SetVariable("quick_menu", True)]
                if "default" in i.args:
                    timer 0.02 repeat True action [If(countdown_time > 0,
                                                    true=[SetVariable('countdown_time', countdown_time-0.02), SetVariable("quick_menu", False)],
                                                    false=[i.action, Call('say_after_choice', i.caption), SetVariable("quick_menu", True)])]
                    
                    bar value countdown_time range countdown_range style "coal_countdown_bar"
                        

    add SideImage() xalign 0.0 yalign 1.0

label say_after_choice(txt=last_choice):
    $ renpy.say(after_choice, txt)
    $ renpy.fix_rollback() #TODO might not be a great idea
    return

User avatar
Alex
Lemma-Class Veteran
Posts: 3094
Joined: Fri Dec 11, 2009 5:25 pm
Contact:

Re: Say something from a screen

#5 Post by Alex »

Amethysts wrote: Wed Jan 20, 2021 5:05 am ...
Hm, I don't get what you try to achieve...
If you use menu then just show the text as a result of choice

Code: Select all

menu:
    "Choice 1":
        e "You choose 1"
My suggestion was about custom screens.

Code: Select all

default my_var = 0

screen test_game_scr():
    
    vbox:
        align(0.5, 0.05)
        textbutton "Text 1" action [SetVariable("my_var", 1), Call('some_say_label', e, "var will be set to 1", from_current=True)]
        textbutton "Text 2" action [SetVariable("my_var", 2), Call('some_say_label', e, "var will be set to 2", from_current=True)]
        textbutton "Text 3" action [SetVariable("my_var", 3), Call('some_say_label', e, "var will be set to 3", from_current=True)]
        textbutton "Done." action Return()

label some_say_label(char, txt):
    $ renpy.say(char, txt)
    return
    
    
# The game starts here.
label start:
    "my_var = [my_var]"
    call screen test_game_scr
    "my_var = [my_var]"
    "?!"

User avatar
xavimat
Eileen-Class Veteran
Posts: 1461
Joined: Sat Feb 25, 2012 8:45 pm
Completed: Yeshua, Jesus Life, Cops&Robbers
Projects: Fear&Love
Organization: Pilgrim Creations
Github: xavi-mat
itch: pilgrimcreations
Location: Spain
Discord: xavimat
Contact:

Re: Say something from a screen

#6 Post by xavimat »

Amethysts wrote: Mon Jan 18, 2021 2:11 pm

Code: Select all

  action Function(renpy.say(choix_resume, i.caption)
I don't know if this will work to do what you want, but this is not how the action Function is used. Parameters must be passed to Function, not to renpy.say.
Comunidad Ren'Py en español: ¡Únete a nuestro Discord!
Rhaier Kingdom A Ren'Py Multiplayer Adventure Visual Novel.
Cops&Robbers A two-player experiment | Fear&Love Why can't we say I love you?
Honest Critique (Avatar made with Chibi Maker by ~gen8)

User avatar
Amethysts
Regular
Posts: 41
Joined: Thu Aug 23, 2018 1:17 pm
Projects: Coalescence
Skype: amethysts-studio
itch: amethysts
Contact:

Re: Say something from a screen

#7 Post by Amethysts »

Alex wrote: Thu Jan 21, 2021 2:20 pm Hm, I don't get what you try to achieve...
If you use menu then just show the text as a result of choice

Code: Select all

menu:
    "Choice 1":
        e "You choose 1"
I just wanted to write down the menu choice the player have chosen.

My game have 150 menus and ~2.5 choices every time : I don't want to write 370 times the previous player's choice.

But I don't know if doing this is relevant. It fits well with NVL-mode though

Post Reply

Who is online

Users browsing this forum: Majestic-12 [Bot]