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 »

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 »

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
Miko-Class Veteran
Posts: 842
Joined: Mon Jan 26, 2009 7:21 pm
Contact:

Re: Random pause time

#3 Post by gas »

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.
If you want to debate on a reply I gave to your posts, please QUOTE ME or i'll not be notified about. << now red so probably you'll see it.

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 »

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: 882
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-3, the Phantom Flyer
itch: per-k-grok
Location: Sverige
Contact:

Re: Random pause time

#5 Post by Per K Grok »

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

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot]