How to turn on and off player input.

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.
Message
Author
zendavis
Regular
Posts: 46
Joined: Thu Nov 13, 2014 2:03 pm
Contact:

How to turn on and off player input.

#1 Post by zendavis »

Basically for my transition sequences. For example when the game fades to black in order to control pacing I want to turn off player input so that when the player clicks on the screen their input does nothing and the game continues through its fade to black transition without being skipped through.

But the game shouldn't out and out pause. It will keep playing through the code written in the script file. Just that the player input is turned off so they can't skip through things. Then when we come back to text box and narrative I would give the player control again so they can click through it once more.

http://i.imgur.com/LUnAPFg.png

The problem with $ renpy.pause(3,hard=True) is that it outright freezes the game rather than turns off player input. So if I use $ renpy.pause(50,hard=True) then the game will pause and freeze for 50 seconds instead of continuing playing for the next 50 seconds with player input turned off. So in this code now here the game will freeze at line 38 and never move on to line 39 for fifty seconds:

http://i.imgur.com/QxY1bCK.png

I'm looking to turn off player input but have the game keep going through the lines.

User avatar
xela
Lemma-Class Veteran
Posts: 2481
Joined: Sun Sep 18, 2011 10:13 am
Contact:

Re: How to turn on and off player input.

#2 Post by xela »

You could try overwriting keybinds for a while or using a bunch of hard pauses instead of one really long one.
Like what we're doing? Support us at:
Image

zendavis
Regular
Posts: 46
Joined: Thu Nov 13, 2014 2:03 pm
Contact:

Re: How to turn on and off player input.

#3 Post by zendavis »

How do I overwrite keybinds?

User avatar
xela
Lemma-Class Veteran
Posts: 2481
Joined: Sun Sep 18, 2011 10:13 am
Contact:

Re: How to turn on and off player input.

#4 Post by xela »

Several ways but no one-liners that I am aware of, there are many posts like this one:

http://lemmasoft.renai.us/forums/viewto ... ut#p259990

Just go through forums...
Like what we're doing? Support us at:
Image

zendavis
Regular
Posts: 46
Joined: Thu Nov 13, 2014 2:03 pm
Contact:

Re: How to turn on and off player input.

#5 Post by zendavis »

But according to that post the person in question never actually got it working. Is there actually a way to turn off player inputs and bring it back?

This code does nothing but freeze the UI when I use it.

Code: Select all

    $ narrator("You can't get rid of this message!", interact=False) 
    $ ui.pausebehavior(5) - 
    $ ui.interact(suppress_overlay = True, suppress_underlay = True)
Last edited by zendavis on Wed May 27, 2015 12:53 pm, edited 1 time in total.

User avatar
xela
Lemma-Class Veteran
Posts: 2481
Joined: Sun Sep 18, 2011 10:13 am
Contact:

Re: How to turn on and off player input.

#6 Post by xela »

? But he was told how to solve it, block all user input by showing a screen or suppress the overlays. I never did either but there shouldn't be a reason for it not to work.

You can use multiple hard pauses instead of one long one.
Like what we're doing? Support us at:
Image

User avatar
xela
Lemma-Class Veteran
Posts: 2481
Joined: Sun Sep 18, 2011 10:13 am
Contact:

Re: How to turn on and off player input.

#7 Post by xela »

Trouble is that you need a good deal of know-how in order to do this properly... "DISABLE USER INPUT" means disabling all input... player will not even be able to turn the game of until you restore controls so you need to know what you're doing.
Last edited by xela on Wed May 27, 2015 1:00 pm, edited 1 time in total.
Like what we're doing? Support us at:
Image

zendavis
Regular
Posts: 46
Joined: Thu Nov 13, 2014 2:03 pm
Contact:

Re: How to turn on and off player input.

#8 Post by zendavis »

xela wrote:? But he was told how to solve it, block all user input by showing a screen or suppress the overlays. I never did either but there shouldn't be a reason for it not to work.

You can use multiple hard pauses instead of one long one.
Hard pauses mess up transitions. For example:

Code: Select all


label start:

stop sound
<---------Turn Off Left-Clicking Here
scene Black space   
with Pause(1)
play music "BG_01_Berkley_Heights_B.mp3"
with Pause(4)
scene BG01_Berkley_Heights     
with Dissolve(3.4)
<---------Turn On Left-Clicking Here.

"I am Samantha Kurosawa and I am freezing. The winter wind cuts through me like a guillotine but I trudge onwards with relentless stubbornness. I will not be stopped tonight." 
The above is what I want to accomplish. Using hard pauses however will cause it look like this.

Code: Select all


label start:

stop sound
scene Black space   
with Pause(1)
play music "BG_01_Berkley_Heights_B.mp3"
with Pause(4)
$ renpy.pause(3,hard=True)
scene BG01_Berkley_Heights     
with Dissolve(3.4)
$ renpy.pause(3,hard=True)

"I am Samantha Kurosawa and I am freezing. The winter wind cuts through me like a guillotine but I trudge onwards with relentless stubbornness. I will not be stopped tonight." 
If a player left-clicks at start it cuts right to the first hard pause. Then when that ends if you click again it cuts right through the first dissolve instead of letting it play through. Then the player is left waiting for the textbox to come up. It's jarring and doesn't work how I'd like it to. I'd like the transition to the scene to work in coordination with the music I've selected and in order to time that correctly I need to control the transitions.

User avatar
xela
Lemma-Class Veteran
Posts: 2481
Joined: Sun Sep 18, 2011 10:13 am
Contact:

Re: How to turn on and off player input.

#9 Post by xela »

Yeah... but you can declare all of that as a single images and put the sounds between two hard-pauses. Use ATL instead of the ancient Pause statement.
Like what we're doing? Support us at:
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: How to turn on and off player input.

#10 Post by trooper6 »

The code from that thread should work fine. I used to use a version of it myself.

You create a screen that takes away all player agency by removing the dismiss actions, and then you show that screen when you want to the player to have no agency. Even when no textbox is on the screen that will work.

Code: Select all

screen my_keys():
    #Dismiss keys
    key "mouseup_1" action NullAction()
    key "K_RETURN" action NullAction()
    key "K_SPACE" action NullAction()
    key "K_KP_ENTER" action NullAction()
    key "joy_dismiss" action NullAction()    
In your code, right before you want to take away the power for you player to interact with the game you just:

Code: Select all

show screen my_keys()
and when you want to give them back agency you:

Code: Select all

hide screen my_keys
You can check out the documentation of the entire keymap to see if you want to similarly disable rollback or rollforward, etc.
http://www.renpy.org/doc/html/keymap.html

There is also the config.say_allow_dismiss variable (http://www.renpy.org/doc/html/config.ht ... ow_dismiss) which I have used to great effect...that effect being a more nuanced way in dealing with how control works and the consequences of that control...but I think you seem to want to take away all user ability to interact with the game...so they key screen is the way to go. Note: some players will hate this...especially on second or third play throughs.
Last edited by trooper6 on Wed May 27, 2015 1:18 pm, edited 1 time in total.
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
xela
Lemma-Class Veteran
Posts: 2481
Joined: Sun Sep 18, 2011 10:13 am
Contact:

Re: How to turn on and off player input.

#11 Post by xela »

LoL I think I figured it out!!!!! Hold on :D


Troopers way is the screen way I mentioned earlier, this is another option:

Code: Select all

init python:
    import pygame
            
label start:
    $ pygame.event.set_allowed(None)
    $ pygame.event.set_allowed(pygame.USEREVENT)
    pause 5
    $ pygame.event.set_blocked(None)
    "LoL"
You can bind that to simple functions so you do not have to type it out all the time. This could in theory have sideeffects as well. Do note that you take controls from player completely and only allow code to proceed (that usually pissed people off (A LOT)).
Last edited by xela on Wed May 27, 2015 1:27 pm, edited 2 times in total.
Like what we're doing? Support us at:
Image

zendavis
Regular
Posts: 46
Joined: Thu Nov 13, 2014 2:03 pm
Contact:

Re: How to turn on and off player input.

#12 Post by zendavis »

Code: Select all

## IT FOLLOWED US HOME DEMO Visual Novel Game Script
## Code by: Zen Davis 
## 05.21.15

screen my_keys():
    #Dismiss keys
    key "mouseup_1" action NullAction()
    key "K_RETURN" action NullAction()
    key "K_SPACE" action NullAction()
    key "K_KP_ENTER" action NullAction()
    key "joy_dismiss" action NullAction()  

                                #GAME RESOLUTION
init python:
    config.screen_width = 1280 
    config.screen_height = 720

                                #MENUS

image splash:                   #Zen Davis Splash Screen Image"
    contains:
        "BG_Splash_Zen_Davis.jpg"
        size(1280, 720)

image splash2:                  #Zen Davis Splash Screen Image With The Word Presents Added
    contains:
        "BG_Splash_Zen_Davis_Presents.jpg"
        size (1280, 720)
        
image Black space:              #Black image to use in case scene is required to be pitch black. 
      contains: 
        "BG_Black_Space.jpg"
        size(1280, 720)

label splashscreen:             #Splash Screen Implementation Including Animations + Dissolve
    
    scene black 
    play sound "BG_00_Intro.mp3"
    with Pause (3)
    show splash with dissolve
    with Pause (3)
    scene splash2 with dissolve
    with Pause(3)
    scene black with dissolve
    with Pause(1)
    return

label main_menu:                #Main Menu Dissolve
    
    with None
    $ renpy.transition(slowdissolve)
    jump main_menu_screen
    with dissolve (8)

                                #BACKGROUNDS 

image BG01_Berkley_Heights: 
    contains:
        "BG_01_Berkley_Heights.jpg"
        size(1280, 720)  

label start:
    
#SCENE01 - PRLOGUE

show screen my_keys()
stop sound                     #Stops Main Menu music
scene Black space               # SCENE 01 - Black Space Introduction
with Pause(1)
play music "BG_01_Berkley_Heights_B.mp3"
with Pause(4)
scene BG01_Berkley_Heights     
with Dissolve(3.4)
scene BG01_Berkley_Heights
with Pause(1)
hide screen my_keys
Like this?

I'm still able to skip through to the end. I'm also using Renpy 6.99 in case that makes a difference. What am I doing wrong?

User avatar
xela
Lemma-Class Veteran
Posts: 2481
Joined: Sun Sep 18, 2011 10:13 am
Contact:

Re: How to turn on and off player input.

#13 Post by xela »

zendavis wrote:I'm still able to skip through to the end.
You need to block skipping key as well in that screen if you use that (screen) way. I've added another option while you were posting*
Like what we're doing? Support us at:
Image

zendavis
Regular
Posts: 46
Joined: Thu Nov 13, 2014 2:03 pm
Contact:

Re: How to turn on and off player input.

#14 Post by zendavis »

xela wrote:
zendavis wrote:I'm still able to skip through to the end.
You need to block skipping key as well in that screen if you use that (screen) way. I've added another option while you were posting*
How do I block the skipping key?

zendavis
Regular
Posts: 46
Joined: Thu Nov 13, 2014 2:03 pm
Contact:

Re: How to turn on and off player input.

#15 Post by zendavis »

xela wrote:LoL I think I figured it out!!!!! Hold on :D


Troopers way is the screen way I mentioned earlier, this is another option:

Code: Select all

init python:
    import pygame
            
label start:
    $ pygame.event.set_allowed(None)
    $ pygame.event.set_allowed(pygame.USEREVENT)
    pause 5
    $ pygame.event.set_blocked(None)
    "LoL"
You can bind that to simple functions so you do not have to type it out all the time. This could in theory have sideeffects as well. Do note that you take controls from player completely and only allow code to proceed (that usually pissed people off (A LOT)).
I'm a little confused as to how I implement it.

Code: Select all

define gamepause = init python:
    import pygame
            
label start:
    $ pygame.event.set_allowed(None)
    $ pygame.event.set_allowed(pygame.USEREVENT)
    pause 5
    $ pygame.event.set_blocked(None)
    "LoL"
Like that?

Post Reply

Who is online

Users browsing this forum: Google [Bot], Ocelot