Disabling clicking when reading a dialogue

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
isobellesophia
Miko-Class Veteran
Posts: 979
Joined: Mon Jan 07, 2019 2:55 am
Completed: None
Projects: Maddox and Friends! (AI Teacher friend), Friendly Universities! (Soon)
Organization: Friendly Teachers series
Deviantart: SophBelle
itch: Child Creation
Location: Philippines, Mindanao
Contact:

Disabling clicking when reading a dialogue

#1 Post by isobellesophia »

Hi,

I wanna ask if how should i do a code, when reading a dialogue, you cannot click it, until the one dialogue finishes.

Can somebody hive me a example?

Thanks.
I am a friendly user, please respect and have a good day.


Image

Image


User avatar
PyTom
Ren'Py Creator
Posts: 16096
Joined: Mon Feb 02, 2004 10:58 am
Completed: Moonlight Walks
Projects: Ren'Py
IRC Nick: renpytom
Github: renpytom
itch: renpytom
Location: Kings Park, NY
Contact:

Re: Disabling clicking when reading a dialogue

#2 Post by PyTom »

No, sorry. Ren'Py intentionally makes it hard to ignore the player's input like this, as when the user clicks, they want to advance through the game.
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
Software > Drama • https://www.patreon.com/renpytom

User avatar
isobellesophia
Miko-Class Veteran
Posts: 979
Joined: Mon Jan 07, 2019 2:55 am
Completed: None
Projects: Maddox and Friends! (AI Teacher friend), Friendly Universities! (Soon)
Organization: Friendly Teachers series
Deviantart: SophBelle
itch: Child Creation
Location: Philippines, Mindanao
Contact:

Re: Disabling clicking when reading a dialogue

#3 Post by isobellesophia »

PyTom wrote: Sun Feb 17, 2019 12:34 am No, sorry. Ren'Py intentionally makes it hard to ignore the player's input like this, as when the user clicks, they want to advance through the game.
Oh, thanks for the advice PyTom, i didn't know that :D
I am a friendly user, please respect and have a good day.


Image

Image


User avatar
Imperf3kt
Lemma-Class Veteran
Posts: 3794
Joined: Mon Dec 14, 2015 5:05 am
itch: Imperf3kt
Location: Your monitor
Contact:

Re: Disabling clicking when reading a dialogue

#4 Post by Imperf3kt »

Which dialogue are you referring to, if it's regular game dialogue, most players won't appreciate being forced to dot through it, but it is possible, however highly discouraged.

But if it's for some other particular use, there may be a reasonable reason for this (a minigame style use comes to mind)
Warning: May contain trace amounts of gratuitous plot.
pro·gram·mer (noun) An organism capable of converting caffeine into code.

Current project: GGD Mentor

Twitter

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: Disabling clicking when reading a dialogue

#5 Post by trooper6 »

What you want is doable, and there are multiple ways to do it. I’m happy to share all the ways, but first I want to ask: Are you sure you want to force the players to read at your pace and not theirs?
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

User avatar
isobellesophia
Miko-Class Veteran
Posts: 979
Joined: Mon Jan 07, 2019 2:55 am
Completed: None
Projects: Maddox and Friends! (AI Teacher friend), Friendly Universities! (Soon)
Organization: Friendly Teachers series
Deviantart: SophBelle
itch: Child Creation
Location: Philippines, Mindanao
Contact:

Re: Disabling clicking when reading a dialogue

#6 Post by isobellesophia »

trooper6 wrote: Sun Feb 17, 2019 10:33 am What you want is doable, and there are multiple ways to do it. I’m happy to share all the ways, bitnforst I want to ask: Are you sure you want to force the players to read at your pace and not theirs?
Yeah, just a few of them, especially at secret times.
I am a friendly user, please respect and have a good day.


Image

Image


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: Disabling clicking when reading a dialogue

#7 Post by trooper6 »

Make a completely new project and put this in the script.rpy file.
Run the project while following along in the script.

Code: Select all

# You can place the script of your game in this file.

# Declare images below this line, using the image statement.
# eg. image eileen happy = "eileen_happy.png"

# Declare characters used by this game.
define a = Character(None, kind=nvl, color="#c8ffc8", what_slow_cps=20, slow_abortable=False, what_xalign=0.5, window_xalign=0.5, what_yalign=0.5, window_yalign=0.5)
define b = Character(None, kind=nvl, color="#c8ffc8", what_slow_cps=20, slow_abortable=False, what_xalign=0.5, window_xalign=0.5, what_yalign=0.5, window_yalign=0.5, callback=nogo)   

init: 
    style nvl_vbox: #This allows you to place NVL text to be centered on both the x axis and the y axis if you want
        xfill True
        yfill True
        
# The game starts here.
label start:
    "First things first. Make sure you are following along with the actual code in your text editor while you run the program."
    "There are multiple ways to block dismissing."
    "I'll try to keep all the code relevant to each option all next to each other."
    "Lastly, since I think the OP wants something that looks like a credit sequence that auto forwards without clicking, 
     I'm going to try and model that, though all the techniques I'm talking about can be used in different circumstances with 
     small changes."
    "Let's begin."
    menu choices:
        "Which option would you like to check out?"
        "Hard Pauses and Text Displayables":
            jump hardpauses
        "Using _dismiss_pause and Text Displayables":
            jump dispause
        "Using a screen to block dismissing":
            jump nodis_screen
        "Using say_allow_dismiss manually":
            jump nodis_func
        "Character Callback Triggering say_allow_dismiss":
            jump nodis_callback
        "Only advance by clicking a button":
            jump nodis_button
        "All Done":
            pass
    "Your Tester is done."
    "But remember! PyTom says blocking dismissal is a) user unfriendly and b) might make the user think the game has crashed."
    "So really think about if you want to actually do it."
    return
    

#####
#Hard Pauses and Text Displayables
#####

#Here we define our text as displables
image end1 = Text("And so the ranch was saved from the Wiplash Gang.", slow=True, slow_cps=20)
image end2 = Text("Jane Barkley became the mayor of the town.", slow=True, slow_cps=20)
image end3 = Text("Chet Li became the new Law Keeper.", slow=True, slow_cps=20)
image end4 = Text("And everyone lived happily ever after.", slow=True, slow_cps=20)

label hardpauses:
    scene black
    "Here, we are showing text displayables using transitions. This could also be other animations."
    "Becasue we are doing this, Hard Pauses are the way to go!"
    "Try to click through while the text is being shown."
    
    show end1 at truecenter
    $renpy.pause(4.0, hard=True)
    hide end1
    show end2 at truecenter
    $renpy.pause(4.0, hard=True)
    hide end2
    show end3 at truecenter
    $renpy.pause(4.0, hard=True)
    hide end3
    show end4 at truecenter
    $renpy.pause(4.0, hard=True)
    hide end4
    
    "You shouldn't have been able to click through."
    "That is how hard pauses with text displayables work."
            
    "Using hard pauses is a thing for stopping people clicking through your animations."
    "Of course, you have to know how long your animations are."
    jump choices
    
#####
# _dismiss_pause and Text Displayables
#####

#Here we define our text as displables
image end1 = Text("And so the ranch was saved from the Wiplash Gang.", slow=True, slow_cps=20)
image end2 = Text("Jane Barkley became the mayor of the town.", slow=True, slow_cps=20)
image end3 = Text("Chet Li became the new Law Keeper.", slow=True, slow_cps=20)
image end4 = Text("And everyone lived happily ever after.", slow=True, slow_cps=20)

label dispause:
    scene black
    "Here, we are showing text displayables using transitions. This could also be other animations."
    "Rather than Hard Pauses, you can set the _dismiss_pause variable to False and block dismissal that way."
    "This seems the more grown up way to do this."
    "Try to click through while the text is being shown."
    
    $_dismiss_pause = False
    show end1 at truecenter
    pause 4.0
    hide end1
    show end2 at truecenter
    pause 4.0
    hide end2
    show end3 at truecenter
    pause 4.0
    hide end3
    show end4 at truecenter
    pause 4.0
    hide end4
    
    "You shouldn't have been able to click through."
    "That is how using _dismiss_pause with text displayables work."
            
    "Using hard pauses is a thing for stopping people clicking through your animations."
    "Of course, you have to know how long your animations are."
    $_dismiss_pause = True
    jump choices
    

#####
#Using a Screen to block dismissal
#####

screen nodismiss(): #Our screen, while it is visible, no one can dismiss anything at all
    key "dismiss" action NullAction()
    
label nodis_screen:
    scene black
    "With this option you are using an NVL character who talks slowly...though it could be an ADV character as well."
    "To stop the user from being able to stop the slow talking, the character has slow_abortable False."
    "To stop the user from being able to click through, show a screen that doesn't allow for any sorts of dismissing."
    
    show screen nodismiss
    a "And so the ranch was saved from the Wiplash Gang.{p=1.0}{nw}"
    nvl clear
    a "Jane Barkley became the mayor of the town.{p=1.0}{nw}"
    nvl clear
    a "Chet Li became the new Law Keeper.{p=1.0}{nw}"
    nvl clear
    a "And everyone lived happily ever after.{p=1.0}{nw}"
    nvl clear
    hide screen nodismiss  
    
    "You shouldn't have been able to click through."
    "That is how using a screen to block dismissing works."
    "As long as your nodis_screen is up, there will be no dismissing of anything."
    "But note! We had to hide that screen right away, or you wouldn't have been able to click through any of this text either!"
    "With that screen up we could have shown a menu, but...after we chose something we wouldn't be able to continue on."
    "So on to other options."

    jump choices
  
  
#####
#Manually using the say_allow_dismiss config variable
#####

default can_cont = True #The variable that will determine if we can dismiss or not
    
init -1 python:
    def dis_block(): #This is the funciton that returns our variable
        global can_cont
        return can_cont
    config.say_allow_dismiss = dis_block #This tells the computer to check our function to see if dismissing is allowed.
    
label nodis_func:
    "Renpy also has a config variable called config.say_allow_dismiss."
    "What it does is run a function. If the function returns True, it allows you to dismiss a say statement. If it returns False, it doesn't."
    "So to use this, you need a function that returns either True or False based on if you want the text to be able to be dismissed."
    "I find the easiest thing to do is have a variable, in our case 'can_cont'. Then I make a funciton dis_block that returns that variable."
    "If I want to stop dismissal, I turn can_cont False. If I want dismissing to be okay, I turn can_cont True."
    "Like so..."
    
    $ can_cont = False
    a "And so the ranch was saved from the Wiplash Gang.{p=1.0}{nw}"
    nvl clear
    a "Jane Barkley became the mayor of the town.{p=1.0}{nw}"
    nvl clear
    a "Chet Li became the new Law Keeper.{p=1.0}{nw}"
    nvl clear
    a "And everyone lived happily ever after.{p=1.0}{nw}"
    nvl clear
    $ can_cont = True  
    
    "You shouldn't have been able to click through."
    "That is how you manually stop dismissing using the say_allow_dismiss config variable."
    "I had to turn it off because otherwise, you wouldn't be able to click through this text either."
    "As long as con_cont is false, there will be no dismissing."
  
    jump choices


#####
#Trigger the say_allow_dismiss config variable function using character callbacks.
#####

#default can_cont = True #The variable that will determine if we can dismiss or not
    
#init -1 python:
#    def dis_block(): #This is the funciton that returns our variable
#        global can_cont
#        return can_cont
#    config.say_allow_dismiss = dis_block #This tells the computer to check our function to see if dismissing is allowed.
    
init -1 python:
    def nogo(event, **kwargs): #This is the character call back we give our character b. While B is talking, it can't be dismissed.
        global can_cont
        if event == "show" or event == "begin":
            can_cont = False
        if event == "slow_done" or event == "end":
            can_cont = True
            
label nodis_callback:
    "Another option is to give specific characters a callback that automatically stops dismissal when they are talking 
     and turns dismissal back on when they finish talking."
    "Why would you do that?" 
    "Well for my game, there is only one character whose dialoge I want to be unskippable (without pressing a button). 
     The other character is totally fine to be skipped through."
    "Remember that you have to make sure the character has the callback on them when you define them...see character b at the top."
    "Also, we are using the can_cont variable and the dis_block function and the config.say_allow_dismiss from the Manual section 
     if you were to only use this option in your game, you'd want to uncomment the commented out repeated code in this section."
    "Here we go..."
    
    b "And so the ranch was saved from the Wiplash Gang."
    nvl clear
    b "Jane Barkley became the mayor of the town."
    nvl clear
    b "Chet Li became the new Law Keeper."
    nvl clear
    b "And everyone lived happily ever after."
    nvl clear
    
    "You shouldn't have been able to click through while the character was talking but should be able to once the text finished."
    "That is how you automatically stop dismissing using the say_allow_dismiss confic variable and a character callback."
    "The cool thing about that is that you can make it character specific."

    jump choices
    
#####
#Only allowing dismissal by pressing a button and the Menu Problem
#####

default is_menu = False

screen nodismiss2(): #Our screen, while it is visible, no one can dismiss anything at all
    key "dismiss" action NullAction()
    textbutton "Dismiss" action Return("smth")
    #textbutton "Dismiss" action If(is_menu, NullAction(), Return("smth"))
    
#init -1 python:
#    def menu(items): #Custom menu that turns off the ability to forward while menu is up
#        renpy.hide_screen("nodismiss2")
#        choice_made=renpy.display_menu(items)        
#        renpy.show_screen("nodismiss2")
#        return choice_made #return the choice
        
#    def menu(items): #Custom menu that turns off the ability to forward while menu is up
#        global is_menu
#        is_menu = True
#        choice_made=renpy.display_menu(items)  
#        is_menu = False
#        return choice_made #return the choice
    
label nodis_button:
    scene black
    "With this option you are using an NVL character who talks slowly."
    "You also have a screen that disables all dismissal, but a button on that screen that will allow you to dismiss instead."
    "Why would you do this? I did this because I wanted that dismiss button to have a few other functions as well, such as 
     tracking how often the text was dismissed."
    "To stop the user from being able to stop the slow talking, the character has slow_abortable False."
    "To stop the user from being able to click through, show a screen that doesn't allow for any sorts of dismissing."
    "To have the button forward, you give it the action Return('smth')"
    "I'd like you to go through this particular option four times."
    
    "First time through. Just go through it and press a menu button not the dismiss button when the menu shows up."
    
    "Second time through, press the dismiss button rather than a menu button when the menu shows up."
    "This should give you an error. This is because the menu is expecting to get a number that represents the choice made, 
     but it is getting the string 'smth' instead."
    "So what do you do?"
    "You have a couple options, I'll give you two of them."
    
    "Third time through uncomment the init -1 python line and the first def menu(items) function above."
    "What that function does is it hides the nodismiss2 screen so that you can't press that button, it takes your menu choice,
     it makes the screen visible again and then returns the menu choice to the menu."
    "Try that out."
    
    "But what if you want the button and screen to remain visible the entire time?"
    "In that case, comment out the first menu function and uncomment the second menu function. Also, comment out the first 
     textbutton and uncomment the second textbutton."
    "With this option the textbutton checks our variable is_menu. If is_menu is True, then the dismiss button doesn't do anything. 
     If is_menu is False, then it returns 'smth'. So that second function? when the menu is called, it makes is_menu True thu making 
     the textbutton useless. Right before it returns the menu choice it turn the is_menu function back to False, thus activating 
     the textbutton again."
    "Try that out."
    
    show screen nodismiss2()
    a "And so the ranch was saved from the Wiplash Gang."
    nvl clear
    a "Jane Barkley became the mayor of the town."
    nvl clear
    a "Chet Li became the new Law Keeper."
    nvl clear
    a "And everyone lived happily ever after."
    nvl clear
    
    "You shouldn't have been able to click through. You can't click through this either without clicking the Dismiss button."
    "That is how using a screen to block dismissing works with a dismiss button."
    
    "This is our menu that I want you to go through four different times to see how it works."
    menu:
        "What do you want for breakfast?"
        "Eggs":
            "Eggs are tasty."
        "Toast":
            "Toast...don't you want more?"
        "French Toast":
            "Eggs and Toast together! Yay"

    hide screen nodismiss2
    "That is what you need to know about blocking dismissal except for a button."
    jump choices

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

User avatar
isobellesophia
Miko-Class Veteran
Posts: 979
Joined: Mon Jan 07, 2019 2:55 am
Completed: None
Projects: Maddox and Friends! (AI Teacher friend), Friendly Universities! (Soon)
Organization: Friendly Teachers series
Deviantart: SophBelle
itch: Child Creation
Location: Philippines, Mindanao
Contact:

Re:(SOLVED) Disabling clicking when reading a dialogue

#8 Post by isobellesophia »

Thank you so much trooper6, this is what ive been looking for! :D
I am a friendly user, please respect and have a good day.


Image

Image


Post Reply

Who is online

Users browsing this forum: AdsBot [Google], Bing [Bot], Google [Bot], Ocelot, snotwurm