Using renpy.random.randint - not working?

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
OpheliaElle
Newbie
Posts: 2
Joined: Sun May 13, 2018 11:00 pm
Contact:

Using renpy.random.randint - not working?

#1 Post by OpheliaElle »

I'm very new to using renpy, and I want to be able to use a random randint to move an image across the screen. This is what I have written:

Code: Select all

show red car:
        xalign 1.0 
    label mcrace:
        $ mcrace = renpy.random.randint(1,2)
        if mcrace == 1:
            show red car:
                xalign 1.0
                linear 1.1
        else:
            show red car:
                xalign 1.0 
                linear 1.2
(So if it gets 1, it will move slightly, if it gets 2, it will move a little bit further).
Unfortunately, my image is not moving at all.
I know this is probably a stupid question with a simple solution, please forgive me because I'm still learning!
I appreciate your help, thank you!

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

Re: Using renpy.random.randint - not working?

#2 Post by Imperf3kt »

renpy.random.randint doesn't refresh instantly.

Try renpy.random.choice instead.
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

User avatar
Alex
Lemma-Class Veteran
Posts: 3094
Joined: Fri Dec 11, 2009 5:25 pm
Contact:

Re: Using renpy.random.randint - not working?

#3 Post by Alex »

Code: Select all

show red car:
        xalign 1.0
Looks like your car is already at finis line, try to change the position

Code: Select all

show red car:
        xalign 0.0 

OpheliaElle
Newbie
Posts: 2
Joined: Sun May 13, 2018 11:00 pm
Contact:

Re: Using renpy.random.randint - not working?

#4 Post by OpheliaElle »

Thank you so much! I knew there had to be something I was overlooking! It works now! :)

Post Reply

Who is online

Users browsing this forum: Google [Bot]