Page 1 of 1

Random pause time

Posted: Mon Jun 18, 2018 9:56 pm
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 ?

Re: Random pause time

Posted: Tue Jun 19, 2018 7:18 am
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".

Re: Random pause time

Posted: Tue Jun 19, 2018 3:41 pm
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.

Re: Random pause time

Posted: Wed Jun 20, 2018 12:22 pm
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.

Re: Random pause time

Posted: Wed Jun 20, 2018 2:30 pm
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