Please explain how the "Time" command works.

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
_king_serj_
Newbie
Posts: 4
Joined: Thu Sep 30, 2021 4:23 pm
Contact:

Please explain how the "Time" command works.

#1 Post by _king_serj_ »

I have a screen that is displayed at a certain point in the game:

Code: Select all

label start:
    scene bg black
    with fade
    
    'Hello'
    
    show screen test_one ### I want it to appear for only 2 seconds, while the game should continue (that is, I don't need the pause function)
    
    menu:
    
        'Hi':
            jump one
            
        'No':
            jump two
            
    #hide screen test_one
I want it to appear for only 2 seconds, while the game should continue. How do I do this in label without changing the settings of the screen itself?
I assume that the "Time" command is needed here, however, no matter how I try, nothing comes out.
It would also be cool if the screen itself would activate not immediately, but after 1 second. Again, I repeat - the game must continue.

Below is the screen code, it loops one action.

Code: Select all

init -501 screen test_one():
    style_prefix "choice"
    
    timer 1/60.0 repeat True action Function(def_test)
Below is the variable that the screen repeats. It loops the cursor on the coordinates:

Code: Select all

init python:
    def def_test():
        currentpos = renpy.get_mouse_pos()
        targetpos = [1500, 600]
        if currentpos[1] < targetpos[0]:
            renpy.display.draw.set_mouse_pos((currentpos[0] * 9 + targetpos[0]) / 10.0, (currentpos[1] * 9 + targetpos[1]) / 10.0)

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

Re: Please explain how the "Time" command works.

#2 Post by Imperf3kt »

Time is not used for this, it is an ATL function.

I would use a timer or kwargs
Something like (not tested, likely to include bugs)

Code: Select all

screen test_one():
    
    timer 2 action Hide(test_one), Return()
    
label start:
    scene bg black
    with fade
    
    'Hello'
    
    show screen test_one
    
    menu:
    
        'Hi':
            jump one
            
        'No':
            jump two
            
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

_king_serj_
Newbie
Posts: 4
Joined: Thu Sep 30, 2021 4:23 pm
Contact:

Re: Please explain how the "Time" command works.

#3 Post by _king_serj_ »

Imperf3kt wrote: Mon Oct 04, 2021 4:38 pm Time is not used for this, it is an ATL function.

I would use a timer or kwargs
Something like (not tested, likely to include bugs)

Code: Select all

screen test_one():
    
    timer 2 action Hide(test_one), Return()
    
label start:
    scene bg black
    with fade
    
    'Hello'
    
    show screen test_one
    
    menu:
    
        'Hi':
            jump one
            
        'No':
            jump two
            
Yes, if you make the "Timer" command in "Screen", then "Screen" is displayed for 2 seconds, but then the meaning of "Screen" itself breaks - that is, the mouse does not move to the desired coordinates. It is for this reason that I did not want to touch the settings of "Screen test_one()"
If you know how to do it correctly, I will be immensely grateful to you!

User avatar
Ocelot
Lemma-Class Veteran
Posts: 2399
Joined: Tue Aug 23, 2016 10:35 am
Github: MiiNiPaa
Discord: MiiNiPaa#4384
Contact:

Re: Please explain how the "Time" command works.

#4 Post by Ocelot »

You can... make two timers each of which doing their own job.

If you really don't want to touch this screen, make another screen which hides first screen and itself on a timer.
< < insert Rick Cook quote here > >

_king_serj_
Newbie
Posts: 4
Joined: Thu Sep 30, 2021 4:23 pm
Contact:

Re: Please explain how the "Time" command works.

#5 Post by _king_serj_ »

Ocelot wrote: Tue Oct 05, 2021 4:31 am You can... make two timers each of which doing their own job.

If you really don't want to touch this screen, make another screen which hides first screen and itself on a timer.
Thanks for the idea. I just created another screen with a timer! And now everything works the way I wanted)

Code: Select all

screen test_one_time():
    timer 1.0 action [Show ("test_one")]
    timer 2.0 action [Hide("test_one")]

Post Reply

Who is online

Users browsing this forum: Andredron, konimyun