Is it possible to limit the numbers of the rng?

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
gaoldart
Regular
Posts: 36
Joined: Wed Jul 06, 2011 11:23 am
Projects: Tony T (Writer, programmer)
Location: Under your chair >8D
Contact:

Is it possible to limit the numbers of the rng?

#1 Post by gaoldart »

Im using the renpy.random.random code... but... is it possible to limit the range of numbers that the code uses?
Bashing my head against the computer desk while programming since march 2011, and so far no brain damashii nanananananananana katamari damashii

User avatar
PyTom
Ren'Py Creator
Posts: 16088
Joined: Mon Feb 02, 2004 10:58 am
Completed: Moonlight Walks
Projects: Ren'Py
IRC Nick: renpytom
Github: renpytom
itch: renpytom
Location: Kings Park, NY
Contact:

Re: Is it possible to limit the numbers of the rng?

#2 Post by PyTom »

Yes. renpy.random has all of the functions in the Python random module. You probably want renpy.random.randint. For example, renpy.random.randint(1, 20) picks an integer between 1 and 20, inclusive, like a die would.

(What do you mean, most people's dice are 6 sided?)
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
Software > Drama • https://www.patreon.com/renpytom

gaoldart
Regular
Posts: 36
Joined: Wed Jul 06, 2011 11:23 am
Projects: Tony T (Writer, programmer)
Location: Under your chair >8D
Contact:

Re: Is it possible to limit the numbers of the rng?

#3 Post by gaoldart »

Wow.. an answer from PyTom himself...
Thank you, that will really help me
Bashing my head against the computer desk while programming since march 2011, and so far no brain damashii nanananananananana katamari damashii

Post Reply

Who is online

Users browsing this forum: GetOutOfMyLab, Majestic-12 [Bot], VESTED