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 » Wed Jun 27, 2018 4:12 am

So I'm using this code to try to get random pause time, but like everything else I ever tried to do with RenPy, it's not working. It's always the same pause time. Is it because always the same one-time-randomly-generated number is called? How do I make it re-roll the number?

Here I define my RNG generator

Code: Select all

  $ dice=renpy.random.randint(1,15)*0.1
Here is where it's not working for some reason? Ignore the silly dialogue, I just made that up.

Code: Select all

    Jimmy "Hahaha I like fart jokes!"
    pause dice
    Svetlana "Hi I'm Svetlana"
    pause dice
    Jimmy "Hahaha that's such a beautiful name"
    pause dice
    Jimmy "Hahaha ..."
If I instead do THIS (which I would think would re-roll the dice before every callign of the number)
$ dice = renpy.random.randint(1,6)*0.1

Code: Select all

    Jimmy "Hahaha I like fart jokes!"
    $ dice = renpy.random.randint(1,6)*0.1
    pause dice
    Svetlana "Hi I'm Svetlana"
    $ dice = renpy.random.randint(1,6)*0.1
    pause dice
    Jimmy "Hahaha that's such a beautiful name"
    $ dice = renpy.random.randint(1,6)*0.1
    pause dice
    Jimmy "Hahaha ..."
I get the following error:

Code: Select all

File "game/script.rpy", line 64: expected 'comma or end of line' not found.
    $ dice = renpy.random.randint(1,6)*0.1

User avatar
Remix
Eileen-Class Veteran
Posts: 1305
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: Random pause time

#2 Post by Remix » Wed Jun 27, 2018 10:32 am

Not entirely sure why your script is throwing an error...

To get round the "same all the time" though, maybe call a function:

Code: Select all

init python:

    def get_random( range=(0.1, 0.6) ):

        return type( range[0] )( 
                      range[0] 
                      + renpy.random.random() 
                        * ( range[1] - range[0] ) )

label start:

    "Start"

    pause get_random()

    "Middle"

    pause get_random( (0.5, 2.0) )

    "End Pauses"

    $ p = get_random()
    "Random = [p!q]"

    $ p = get_random()
    "Random = [p!q]"

    $ p = get_random()
    "Random = [p!q]"

    $ p = get_random( (1, 50) ) ## integers not floats test
    "Random = [p!q]"
Mad Scientist Todo List:
  • Finish Improved Event Handler
  • Implement DragonBones animation as a Creator Defined Container
  • Develop Cartoon Speech Bubble dialogue
  • Finish Bitmask collision and rebound vector system
  • Develop time based building mechanic
  • Others
  • *Find a superb artist and actually write a game*

User avatar
Per K Grok
Miko-Class Veteran
Posts: 537
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

#3 Post by Per K Grok » Wed Jun 27, 2018 2:40 pm

gamajorbatistan wrote:
Wed Jun 27, 2018 4:12 am
----

If I instead do THIS (which I would think would re-roll the dice before every callign of the number)
$ dice = renpy.random.randint(1,6)*0.1

Code: Select all

    Jimmy "Hahaha I like fart jokes!"
    $ dice = renpy.random.randint(1,6)*0.1
    pause dice
    Svetlana "Hi I'm Svetlana"
    $ dice = renpy.random.randint(1,6)*0.1
    pause dice
    Jimmy "Hahaha that's such a beautiful name"
    $ dice = renpy.random.randint(1,6)*0.1
    pause dice
    Jimmy "Hahaha ..."
I get the following error:

Code: Select all

File "game/script.rpy", line 64: expected 'comma or end of line' not found.
    $ dice = renpy.random.randint(1,6)*0.1

I've duplicated your code and tested it in my game (using a bit of dialogue from that game).

Code: Select all

    jp "Claude! Do you hear that?"
    $ dice = renpy.random.randint(1,6)*0.1
    pause dice
    cl "The aeroplane? Of course I hear it, Jean Pierre. [dice]"
    $ dice = renpy.random.randint(1,6)*0.1
    pause dice
    jp "Is it a Nieuport? [dice]"
    $ dice = renpy.random.randint(1,6)*0.1
    pause dice
    cl "Yes. It sounds like that engine has taken a beating. [dice]"
In each line of dialogue I have also added the value of dice at the time.

I get no error and
for each line I get a different value for dice.

I have no idea what could wrong in your code, but the 'random generator' seem to do it's job.

I also wonder a bit on the purpose of having a pause that delays the showing of the next line of dialogue, and a random pause at that.
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: No registered users