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: 198
Joined: Sun Oct 23, 2016 3:51 am
Completed: My Dream Sport Dating Simulator, Attack Helicopter Dating Simulator
Projects: My Dream Sport Dating Simulator, Attack Helicopter Dating Simulator
Deviantart: neometalero
Contact:

How to use Random on Variables

#1 Post by neometalero »

I want to know how can I create a random between 1 and 10 for example to use on a variable.
Working on many weird narrative games at Curse Box Studios
Image
https://www.curseboxstudios.com/

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 »

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: 198
Joined: Sun Oct 23, 2016 3:51 am
Completed: My Dream Sport Dating Simulator, Attack Helicopter Dating Simulator
Projects: My Dream Sport Dating Simulator, Attack Helicopter Dating Simulator
Deviantart: neometalero
Contact:

Re: How to use Random on Variables

#3 Post by neometalero »

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 many weird narrative games at Curse Box Studios
Image
https://www.curseboxstudios.com/

Post Reply

Who is online

Users browsing this forum: Google [Bot]