Page 1 of 1

Displaying text lines in a screen one at a time

Posted: Fri Mar 25, 2022 11:47 pm
by Michael Regal
Hi there!

This might be a basic fix, it might not be, but I'm looking to display a bunch of lines inside a screen one by one instead of all at once.

Image

When the player clicks "roll dice" all this text is displayed at once, but I would like the lines of text to be displayed one at a time with some sort of wait or pause command if this exists.

My code follows, and I thank you for your consideration.

Code: Select all

screen hazard:
    modal True
    frame:
        xpadding 20
        ypadding 20
        xalign 0.5
        yalign 0.5
        side ("c r"):
            area (1,0,280,600)
            viewport id "my_scroller":
                draggable True mousewheel True
                textbutton "{image=close.png}" action [Play("sound", "audio/pageturn.ogg"), Return()] at topright
                vbox:
                    spacing 10
                    null height 40
                    text "[player_name] rolls, with the main of [hazard_main]."
                    if Dicerolled == False:
                        textbutton "Roll Dice." action [Play("sound", "audio/diceroll.ogg"), SetVariable("d6One", renpy.random.randint(1,6)), SetVariable("d6Two", renpy.random.randint(1,6)), SetVariable("Dicerolled", True)]
                    else:
                        text "[player_name] has rolled {image=[d6One]_dice.png} and {image=[d6Two]_dice.png}."
                        null height 10
                        if d6One + d6Two == hazard_main or d6One + d6Two + 1 == hazard_main or d6One + d6Two - 1 == hazard_main:
                            text "[player_name] has rolled well, and is near the chosen main!"
                            $ hazard_victory_flag = 1
                            null height 10
                        else:
                            text "[player_name] has rolled poorly. The pot goes to [caster]."
                            null height 10

                    if hazard_victory_flag == 1:
                        $ hazard_npc_main = renpy.random.randint(5,9)

                        text "[caster] rolls, with the main of [hazard_npc_main]."
                        null height 10
                        $ d6One_npc = renpy.random.randint(1,6)
                        $ d6Two_npc = renpy.random.randint(1,6)
                        text "[caster] has rolled {image=[d6One_npc]_dice.png} and {image=[d6Two_npc]_dice.png}."
                        null height 10
                        if d6One_npc + d6Two_npc == hazard_npc_main or d6One_npc + d6Two_npc == hazard_npc_main or d6One_npc + d6Two_npc + 1 == hazard_npc_main or d6One_npc + d6Two_npc - 1 == hazard_npc_main:
                            text "[caster] has rolled well, and is near the chosen main! The pot goes to [caster]."
                            null height 10
                        else:
                            text "[caster] has rolled poorly. The pot goes to [player_name]."
                            null height 10
               vbar value YScrollValue("my_scroller") 

Re: Displaying text lines in a screen one at a time

Posted: Sat Mar 26, 2022 12:51 am
by rayminator
you can put them into their own text or \n for the next line

Code: Select all

text "[caster] has rolled poorly. \nThe pot goes to [player_name]."

Code: Select all

text "[caster] has rolled poorly."
text "The pot goes to [player_name]."

Re: Displaying text lines in a screen one at a time

Posted: Sat Mar 26, 2022 1:08 am
by Michael Regal
rayminator wrote:
Sat Mar 26, 2022 12:51 am
you can put them into their own text or \n for the next line

Code: Select all

text "[caster] has rolled poorly. \nThe pot goes to [player_name]."

Code: Select all

text "[caster] has rolled poorly."
text "The pot goes to [player_name]."
While I see your logic, this still displays all the text instantaneously. Thank you though.

Re: Displaying text lines in a screen one at a time

Posted: Sat Mar 26, 2022 2:38 am
by Ocelot

Code: Select all

define words = """According to all known laws of aviation, there is no way a bee should be able to fly.{p=3}
Its wings are too small to get its fat little body off the ground.{p=3}
The bee, of course, flies anyway because bees don't care what humans think is impossible."""

screen display_text():
    text words:
        slow_cps 10 # How fast text is appearing. use True to take from Text Speed Preference
        slow_abortable True # Can click text to display instantly

label start:
    ' . '
    show screen display_text
    ' . . . '

    return

Re: Displaying text lines in a screen one at a time

Posted: Sat Mar 26, 2022 6:29 am
by Michael Regal
Ocelot wrote:
Sat Mar 26, 2022 2:38 am

Code: Select all

define words = """According to all known laws of aviation, there is no way a bee should be able to fly.{p=3}
Its wings are too small to get its fat little body off the ground.{p=3}
The bee, of course, flies anyway because bees don't care what humans think is impossible."""

screen display_text():
    text words:
        slow_cps 10 # How fast text is appearing. use True to take from Text Speed Preference
        slow_abortable True # Can click text to display instantly

label start:
    ' . '
    show screen display_text
    ' . . . '

    return
I might be able to work with this, thank you!