Prevent clicking

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
Nobbelz
Newbie
Posts: 12
Joined: Mon Jul 03, 2017 6:26 pm
Projects: Project: Heartbeat.
Location: Portugal
Contact:

Prevent clicking

#1 Post by Nobbelz »

Hi,

is it possible to prevent the player from clicking for a set amount of time in Ren'Py? It seems the pause command only pauses the script, but as soon the player clicks, the pause is skipped.

Why/how do i want to use it?
I want to show a series of pictures (think of credits in game with different screen arts popping up)

Thanks very much for any help on this!
Last edited by Nobbelz on Thu Jul 06, 2017 1:08 pm, edited 1 time in total.
Current Project:
Image


User avatar
Nobbelz
Newbie
Posts: 12
Joined: Mon Jul 03, 2017 6:26 pm
Projects: Project: Heartbeat.
Location: Portugal
Contact:

Re: Prevent clicking

#3 Post by Nobbelz »

Looks good, but 2 questions:

Won't that statement pause the whole script? So if i have several pictures, wouldn't it stop playing them while preventing clicking?

And how exactly do i have to put this line into the script? I tried several ways now, which all got my an error crashing my game :/
Last edited by Nobbelz on Thu Jul 06, 2017 1:08 pm, edited 1 time in total.
Current Project:
Image

User avatar
DannyGMaster
Regular
Posts: 113
Joined: Fri Sep 02, 2016 11:07 am
Contact:

Re: Prevent clicking

#4 Post by DannyGMaster »

It doesn't stop playing the pictures if you show them first then do the hard pause. For example:

Code: Select all

label pause_test:

    "Testing"

    show my_image 

    window hide # if you don't want the textbox to be visible during the pause

    $ renpy.pause(2, hard=True) 

    "The game continues"
The first argument (2 in the example), is the amount of time in seconds you want the pause to last,
and hard=True makes it so the player can't skip it. You should be careful though as like the documentation says it's hard to tell apart a hard pause from a game crash, unless you have some animation playing.
The silent voice within one's heart whispers the most profound wisdom.

User avatar
Nobbelz
Newbie
Posts: 12
Joined: Mon Jul 03, 2017 6:26 pm
Projects: Project: Heartbeat.
Location: Portugal
Contact:

Re: Prevent clicking

#5 Post by Nobbelz »

Thank you for the fast reply, but i think the way i have scripted my scene, it wont work with the hard pause. What i try to make is some kind of jumpscare with the following code:

Code: Select all

    scene y
    with dissolve
    scene x
    with dissolve
    scene c
    with dissolve
    scene v
    with dissolve
    play sound "scare.mp3"
    scene b
    with hpunch
    scene v
    pause 0.3
    scene b
    pause 0.1
    scene v
    pause 0.2
    scene b
    pause 0.1
    scene v
    pause 0.1
    scene b
    pause 0.1
    scene v
    with dissolve
    pause 5
    pause 0.1
    scene gb_schwarz
Which ingame leads to this:

Warning, reduce sound volume before opening the link...
Youtube

The problem i have is, that the whole part is skipped as soon the player clicks.
Current Project:
Image

User avatar
DannyGMaster
Regular
Posts: 113
Joined: Fri Sep 02, 2016 11:07 am
Contact:

Re: Prevent clicking

#6 Post by DannyGMaster »

Ah, I see now. You may want to look into ATL in
general, specially here, and define the entire sequence as an image like the example in this last link, if the pause statement still doesn't work try the time statement https://www.renpy.org/doc/html/atl.html#time-statement
The silent voice within one's heart whispers the most profound wisdom.

User avatar
Nobbelz
Newbie
Posts: 12
Joined: Mon Jul 03, 2017 6:26 pm
Projects: Project: Heartbeat.
Location: Portugal
Contact:

Re: Prevent clicking

#7 Post by Nobbelz »

Ok, that will take some time till i understand this. But can i still include the soundeffect into it? How i understand the site you linked, thats for image manipulation only?
Current Project:
Image

User avatar
DannyGMaster
Regular
Posts: 113
Joined: Fri Sep 02, 2016 11:07 am
Contact:

Re: Prevent clicking

#8 Post by DannyGMaster »

Yes, ATL is only for image manipulation, making the flashing images a transform would hopefully solve the prevent clicking problem, wich is was this thread's main objective (was it not?), playing the sound is a separate issue, but you could define two different sequences.

Code: Select all

show scare_intro #The first, slow sequence of images with dissolve

#Or you could alternatively show the separate scenes

play sound "scare.mp3"

show scary_lady #The fast jumpscare sequence, wich I suppose is the one you don't want to skip
Last edited by DannyGMaster on Thu Jul 06, 2017 1:59 pm, edited 2 times in total.
The silent voice within one's heart whispers the most profound wisdom.

User avatar
Nobbelz
Newbie
Posts: 12
Joined: Mon Jul 03, 2017 6:26 pm
Projects: Project: Heartbeat.
Location: Portugal
Contact:

Re: Prevent clicking

#9 Post by Nobbelz »

DannyGMaster wrote:

Code: Select all

show scare_intro #The first, slow sequence of images with dissolve

#Or you could alternatively show the separate scenes

play sound "scare.mp3"

show scary_lady #The fast jumpscare sequence, wich I suppose is the one you don't want to skip
Yes, the main objective was the hard pause. But that idea should solve the problem i quess. I will try around the next few days and post my result here then :)
Current Project:
Image

User avatar
Remix
Eileen-Class Veteran
Posts: 1628
Joined: Tue May 30, 2017 6:10 am
Completed: None... yet (as I'm still looking for an artist)
Projects: An un-named anime based trainer game
Contact:

Re: Prevent clicking

#10 Post by Remix »

A few notes and a bit of code to hopefully give you some options...

ATL does not support audio though it can run a python function inline (see code)
I am not certain if ATL displays scenes or if just images are ok for you.
Anyway, some sample code to get the audio working:

Code: Select all

define forest = Image("images/forest.png")
init python:
    def play_audio_in_atl(trans, st, at):
        # we ignore the vars and just use python to play
        renpy.music.set_pause(True, channel='music')
        # I had to test with something
        renpy.play("Addams Family TV Theme Song.mp3")
        renpy.music.set_pause(False, channel='music')
        return None

label start:
    "Hi"
    show forest:
        xalign 0.0
        linear 1.0 xalign 1.0
        1.0
        linear 1.0 xalign 0.0
        1.0
        linear 1.0 xalign 1.0
        1.0
        parallel:
            linear 1.0 xalign 0.0
            function play_audio_in_atl
            # The music starts here while the above 'parallel' atl runs
        1.0
        linear 1.0 xalign 1.0
        1.0
        linear 1.0 xalign 0.0
        1.0
        linear 1.0 xalign 1.0
    # Finished the atl... continue story
    "Next"
Note: The music will continue until file is done, the atl parts will continue with music playing if they are scheduled to run before the jump-scare stops.

Hope that snippet helps.
Frameworks & Scriptlets:

User avatar
Nobbelz
Newbie
Posts: 12
Joined: Mon Jul 03, 2017 6:26 pm
Projects: Project: Heartbeat.
Location: Portugal
Contact:

Re: Prevent clicking

#11 Post by Nobbelz »

Just got an idea on my code. Would it be possible to bring something like that in? It doesn't work that way, but is there a possibility to make it run?

while $ renpy.pause(10, hard=True):#then my code

Code: Select all


    scene y
    with dissolve
    scene x
    with dissolve
    scene c
    with dissolve
    scene v
    with dissolve
    play sound "scare.mp3"
    scene b
    with hpunch
    scene v
    pause 0.3
    scene b
    pause 0.1
    scene v
    pause 0.2
    scene b
    pause 0.1
    scene v
    pause 0.1
    scene b
    pause 0.1
    scene v
    with dissolve
    pause 5
    pause 0.1
    scene gb_schwarz
[/quote]
Current Project:
Image

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

Re: Prevent clicking

#12 Post by Imperf3kt »

Theoretically, I suppose it should work if you use conditional statements, but unless you reuse this a lot, it will be more coding and more complex than just doing the previously mentioned suggestions.
Also, you could add a delay to the audio so it starts when the block of code does, but it won't start playing for x seconds.
Might be useful if other methods don't work as desired.
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
Remix
Eileen-Class Veteran
Posts: 1628
Joined: Tue May 30, 2017 6:10 am
Completed: None... yet (as I'm still looking for an artist)
Projects: An un-named anime based trainer game
Contact:

Re: Prevent clicking

#13 Post by Remix »

As Imperf3kt says, a delayed audio prior to some ATL might be one of the simplest ways, something like:

Code: Select all

     # 2 seconds of silence followed by scare
    play sound ["<silence 2.0>", "scare.mp3"]
    show y with Dissolve(0.5):
        x with Dissolve(0.5)
        c with Dissolve(0.5)
        v with Dissolve(0.5)
        b with hpunch
        pos (0,0)
        pause 0.25
        v
        0.3
        b
        0.1
        v
        0.2
        b
        0.1
        v
        0.1
        b
        0.1
        v with dissolve
        5
        0.1
        gb_schwarz
So saying, when I ran that mine wasn't too great with the transition durations and pauses.
You might be able to tweak it to your needs though.
Frameworks & Scriptlets:

User avatar
IrinaLazareva
Veteran
Posts: 399
Joined: Wed Jun 08, 2016 1:49 pm
Projects: Legacy
Organization: SunShI
Location: St.Petersburg, Russia
Contact:

Re: Prevent clicking

#14 Post by IrinaLazareva »

Code: Select all

screen death():
    button:
        xysize(1280, 720) # the width and height of the screen
        background "#0000"
        action NullAction()
    
    
label start:
    
    show screen death

    scene y
    with dissolve
    scene x
    with dissolve
    scene c
    with dissolve
    scene v
    with dissolve
    play sound "scare.mp3"
    scene b
    with hpunch
    scene v
    pause 0.3
    scene b
    pause 0.1
    scene v
    pause 0.2
    scene b
    pause 0.1
    scene v
    pause 0.1
    scene b
    pause 0.1
    scene v
    with dissolve
    pause 5
    pause 0.1
    scene gb_schwarz
    
    hide screen death
viewtopic.php?f=8&t=42331

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot]