How to use Random on Variables

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
User avatar
neometalero
Regular
Posts: 109
Joined: Sun Oct 23, 2016 3:51 am
Deviantart: neometalero
Contact:

How to use Random on Variables

#1 Post by neometalero » Sat Jan 28, 2017 11:18 pm

I want to know how can I create a random between 1 and 10 for example to use on a variable.
Working on My Dream Sport Dating Simulator
Image
Image

User avatar
Onomatopoeia
Regular
Posts: 40
Joined: Wed Jan 11, 2012 7:36 pm
Location: GA
Contact:

Re: How to use Random on Variables

#2 Post by Onomatopoeia » Sun Jan 29, 2017 12:14 am

Hello, new friend! You'd use the 'random' code for that. The exact code to use would be:

Code: Select all

renpy.random.randint(1, 10)
It may do you well to check out the 'Other Functions' documentation (https://www.renpy.org/doc/html/other.html), there are all sorts of fun codes on that page. Random is located at the very bottom.

User avatar
neometalero
Regular
Posts: 109
Joined: Sun Oct 23, 2016 3:51 am
Deviantart: neometalero
Contact:

Re: How to use Random on Variables

#3 Post by neometalero » Sat Feb 04, 2017 7:04 pm

Onomatopoeia wrote:Hello, new friend! You'd use the 'random' code for that. The exact code to use would be:

Code: Select all

renpy.random.randint(1, 10)
It may do you well to check out the 'Other Functions' documentation (https://www.renpy.org/doc/html/other.html), there are all sorts of fun codes on that page. Random is located at the very bottom.
Tks a lot, I will read that. If I want to store this random variable for future use would be something like this?

Code: Select all

$ d10roll = renpy.random.randint(1,10) 
being d10roll the variable where the number get stored right?
Working on My Dream Sport Dating Simulator
Image
Image

Post Reply

Who is online

Users browsing this forum: Google [Bot]