Page 2 of 2

Re: How to turn on and off player input.

Posted: Wed May 27, 2015 1:35 pm
by trooper6
The code I give works for me.
Make a brand new fresh project with this code in your script.rpy

Code: Select all

define e = Character('Eileen', color="#c8ffc8")

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()  

# The game starts here.
label start:
    
    e "You've created a new Ren'Py game."
    show screen my_keys()

    e "Once you add a story, pictures, and music, you can release it to the world!"
    hide screen my_keys
    return
Then try to move past the second Eileen line. You won't be able to, proving that this method does actually work. Then we can look at what is going on with your implementation.

Re: How to turn on and off player input.

Posted: Wed May 27, 2015 1:40 pm
by zendavis
Got it working! I love you! Thank you so much!

Xela's method worked. I'm going to try Trooper's right now.

Re: How to turn on and off player input.

Posted: Wed May 27, 2015 1:41 pm
by xela
zendavis wrote:
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?
http://www.renpy.org/doc/html/keymap.html

Find keybinds that you want to block here and add them to the screen.

zendavis wrote:Like that?
No, just put your animation/transition where """pause 5""" currently is and see if it works for you. Because you still need to somehow know when to restore controls... but you can prolly just use pause statement since they cannot be interrupted anymore.

But as long as it's solved :)

Re: How to turn on and off player input.

Posted: Wed May 27, 2015 1:42 pm
by zendavis

Code: Select all

init python:
    import pygame
            
label start:
$ pygame.event.set_allowed(None)
$ pygame.event.set_allowed(pygame.USEREVENT)    
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)
$ pygame.event.set_blocked(None)

"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." 
That worked!

Re: How to turn on and off player input.

Posted: Wed May 27, 2015 1:44 pm
by xela
Cool, same thing, just simplified:

Code: Select all

init python:
    import pygame
    
    def kill_all_ui():
        pygame.event.set_allowed(None)
        pygame.event.set_allowed(pygame.USEREVENT)
        
    def restore_ui():
        pygame.event.set_blocked(None)
            
label start:
    $ kill_all_ui()
    # ANY ANIMATIONS OR TRANSITIONS GO HERE.
    $ restore_ui()
You do not have to remember/copy/paste the lines this way.

Re: How to turn on and off player input.

Posted: Wed May 27, 2015 1:48 pm
by zendavis
trooper6 wrote:The code I give works for me.
Make a brand new fresh project with this code in your script.rpy

Code: Select all

define e = Character('Eileen', color="#c8ffc8")

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()  

# The game starts here.
label start:
    
    e "You've created a new Ren'Py game."
    show screen my_keys()

    e "Once you add a story, pictures, and music, you can release it to the world!"
    hide screen my_keys
    return
Then try to move past the second Eileen line. You won't be able to, proving that this method does actually work. Then we can look at what is going on with your implementation.
I tested this. This looks to only work when there is text on the screen. When you remove text and only have images you can still skip through them.

Re: How to turn on and off player input.

Posted: Wed May 27, 2015 1:58 pm
by xela
zendavis wrote:I tested this. This looks to only work when there is text on the screen. When you remove text and only have images you can still skip through them.
It doesn't block user-input, it just reassigns keys while the screen is shown. Just with those keys it is to a degree useless as it will not prevent skipping (everything), will not prevent rollbacks unless implicitly disabled before the menu/preferences and skipping of animations/transitions without additional code.

But it is a LOT more gentle and you have a far better control of what user should be allowed to do... You can also mess with config.keymap/config.default_keymap which will serve in a very similar way and you can disable controls by their functionality instead of specific keys.

There are lots of ways... like with everything else in the Ren'Py. I still think best way was to use ATL for your transitions/animations with a hard or normal pause but whatever works for you :)

Re: How to turn on and off player input.

Posted: Wed May 27, 2015 2:06 pm
by zendavis
How would I use ATL?

Zen

Re: How to turn on and off player input.

Posted: Wed May 27, 2015 2:18 pm
by xela
zendavis wrote:How would I use ATL?

Zen
I haven't tested your code so it's hard to rewrite it, I just know that I had (a lot of) issues like yours (animation control vs user input) and always solved these things with atl (it's documented but requires a bit of getting used to and going over this forum sections for examples).

Like I've said, as long as it works for you :)

Re: How to turn on and off player input.

Posted: Wed May 27, 2015 2:50 pm
by trooper6
I still think hard pauses for graphics are the way to go here, with the key screen only if you need to deal with text. I looked at your original code you said wouldn't work with hard pauses:

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."
Now I was a bit confused about why you had play music with a pause of 4 followed by a pause of 3. I'm going to assume this means you just want a 7 second pause. If you just write it so, you should be fine (I just tested this and it worked for me):

Code: Select all

define odd_dissolve = Dissolve(3.4)

label start:
    stop sound
    scene black #you don't need your own black image, you can use the default 
    $ renpy.pause(1,hard=True)
    play music "BG_01_Berkley_Heights_B.mp3"
    $ renpy.pause(7,hard=True)
    $ renpy.transition(odd_dissolve)
    scene BG01_Berkley_Heights     
    $ 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."
No dismissing allowed because of the hard pauses, but the game keeps going the way you wanted it to.

Re: How to turn on and off player input.

Posted: Wed May 27, 2015 4:08 pm
by xela
I didn't even know one could use a transition over music... with Pause() is supposed to show a displayable for a specified delay, not set a pause of any kind (unless I got confused by documentation, I never used it once in almost 3 years of using Ren'Py).

At the end of the day you can do anything with Screens/ATL/UDD/DD or combination of some/all. Which one is right for the occasion you will only know from experience. But as far as the name of the thread (turning on/off player input), my suggestion does the trick :)

Re: How to turn on and off player input.

Posted: Thu Jul 18, 2019 12:36 am
by wellsgrant
You could do something like this

Code: Select all

label loop:
    P "{color=#f00}{b}{fast}loop{/b}{/color}{nw}"
    jump loop

Re: How to turn on and off player input.

Posted: Thu Jul 18, 2019 12:47 am
by trooper6
That is an unending loop the program never gets out of. Why would you want that?

Re: How to turn on and off player input.

Posted: Thu Jul 18, 2019 1:24 am
by Imperf3kt
trooper6 wrote: Thu Jul 18, 2019 12:47 am That is an unending loop the program never gets out of. Why would you want that?
Probably related to this
viewtopic.php?f=8&t=56128&p=515128#p515126

Yet another DDLC inspired game?

Re: How to turn on and off player input.

Posted: Sun Oct 27, 2019 11:46 am
by Chiligoat
Sorry for necroing this thread yet again, but for me this is a recurring issue that none of the above solutions have fixed so far.

I would have thought that a modal screen should suffice, but nope.. Modal screen, screen that turns off key inputs, screen with a transparent button that does nothing, a high zorder screen... all of these still allow user input to click straight through all my transforms. Using xela's ui shutdown acts as a hard pause for me through which the transforms refuse to act (and also prevents you from just hard-x:ing out of the application itself, to boot).

It's not just about "oh, the users need to see these nifty animations!" but I'm thinking about people like my partner, who has involuntary neurological finger twitches that frequently make him click when or where he didn't mean to. Ren'py's text rollback is great to fix that stuff, but animations are often one time only, and I just dearly want to stop for like.. eight seconds?
Any takers?