Random pause time

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
gamajorbatistan
Regular
Posts: 35
Joined: Sun Mar 04, 2018 3:57 am
Contact:

Random pause time

#1 Post by gamajorbatistan » Mon Jun 18, 2018 9:56 pm

How can I implement a random pause in my game?

I've done plenty of googling and forum browsing but nothing seemed to work, when it should be such a simple straight-forward thing to do ?

kivik
Miko-Class Veteran
Posts: 786
Joined: Fri Jun 24, 2016 5:58 pm
Contact:

Re: Random pause time

#2 Post by kivik » Tue Jun 19, 2018 7:18 am

Can you explain what you mean with a bit more details? What do you want to happen?

For example this could be interpreted as "randomly the game pauses" or "the game pauses for a random amount of time".

User avatar
gas
Veteran
Posts: 450
Joined: Mon Jan 26, 2009 7:21 pm
Contact:

Re: Random pause time

#3 Post by gas » Tue Jun 19, 2018 3:41 pm

If you want for a pause that last a random amount of time...

Code: Select all

    $ dice=renpy.random.randint(1,10)
    $ renpy.pause(dice,hard=True)
In this case, pause last from 1 to 10 seconds (broadly, it's never so precise). If you want for the player to click and skip the pause, remove the hard=True part.
10 ? "RENPY"
20 GOTO 10

RUN

gamajorbatistan
Regular
Posts: 35
Joined: Sun Mar 04, 2018 3:57 am
Contact:

Re: Random pause time

#4 Post by gamajorbatistan » Wed Jun 20, 2018 12:22 pm

gas wrote:
Tue Jun 19, 2018 3:41 pm
If you want for a pause that last a random amount of time...

Code: Select all

    $ dice=renpy.random.randint(1,10)
    $ renpy.pause(dice,hard=True)
In this case, pause last from 1 to 10 seconds (broadly, it's never so precise). If you want for the player to click and skip the pause, remove the hard=True part.
Awesome, thank you! There's only one issue I've got now. What if I need random pause times in the decimal range? Integer surely doesn't work, but if I did this (I'm sure it doesn't work but let's just say it did)

Code: Select all

$ dice=renpy.random.real(0.1,1.5)
then python wouldn't know how many decimals to include in the randomly generated number, right? So what would you do in this situation?
I've thought of using 'choose' instead and have the function randomly pick one time out of a provided list, but I got weird errors trying that too.
kivik wrote:
Tue Jun 19, 2018 7:18 am
Can you explain what you mean with a bit more details? What do you want to happen?

For example this could be interpreted as "randomly the game pauses" or "the game pauses for a random amount of time".
Well I just want to know how to implement random pauses in general.

User avatar
Per K Grok
Miko-Class Veteran
Posts: 541
Joined: Fri May 18, 2018 1:02 am
Completed: the Ghost Pilot, Sea of Lost Ships, Bubbles and the Pterodactyls, Defenders of Adacan Part 1
Projects: Defenders of Adacan Part 2
Deviantart: pekj
itch: per-k-grok
Location: Sverige
Contact:

Re: Random pause time

#5 Post by Per K Grok » Wed Jun 20, 2018 2:30 pm

gamajorbatistan wrote:
Wed Jun 20, 2018 12:22 pm
---
There's only one issue I've got now. What if I need random pause times in the decimal range?
---
Just enter integers 10 time the float value you want to use and then multiply the returned value with 0.1

Code: Select all

    $ dice=renpy.random.randint(1,15)*0.1
'dice' should now become a float between 0.1 and 1.5
Image Visual Story Telling, DeviantArt Group for animations, comics, games and illustrations https://www.deviantart.com/acgi

Post Reply

Who is online

Users browsing this forum: Google [Bot]