DICE ROLL and if statements
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.
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.
-
- Regular
- Posts: 60
- Joined: Sat Jan 04, 2014 12:52 am
- Location: Canada
- Contact:
DICE ROLL and if statements
I want to do a dice roll
and the result activates an if statement:
1-10 activates if statement A
11-20 activates if statement B'
\m/Timberduck\m/
and the result activates an if statement:
1-10 activates if statement A
11-20 activates if statement B'
\m/Timberduck\m/
Re: DICE ROLL and if statements
You should be able to achieve that through normal conditionals and a random integer. It shouldn't require any changes or additions to Ren'Py.
Don't remember the syntax off the top of my head, but python has randint-
dice = randint(1,11)
if dice <= 10
statement a
Don't remember the syntax off the top of my head, but python has randint-
dice = randint(1,11)
if dice <= 10
statement a
-
- Regular
- Posts: 60
- Joined: Sat Jan 04, 2014 12:52 am
- Location: Canada
- Contact:
Re: DICE ROLL and if statements
Cool thanks
I just need to play around with it.
XD
I just need to play around with it.
XD
-
- Regular
- Posts: 60
- Joined: Sat Jan 04, 2014 12:52 am
- Location: Canada
- Contact:
Re: DICE ROLL and if statements
actually my problem is displying the number i keep getting error messages and have no clue what is the issue.
-
- Regular
- Posts: 60
- Joined: Sat Jan 04, 2014 12:52 am
- Location: Canada
- Contact:
Dice roll #2
I am trying to get Dice roll to work
my problem is displaying the roll.
I have spent a few hours already and I am just about to defenestrate my computer into my monitor.
just need an answer.
\m/Timberduck\m/
my problem is displaying the roll.
I have spent a few hours already and I am just about to defenestrate my computer into my monitor.
just need an answer.
\m/Timberduck\m/
-
- King of Lolies
- Posts: 4538
- Joined: Mon Nov 26, 2007 9:57 pm
- Completed: R.S.P
- Location: Bandung, West Java, Indonesia
- Contact:
Re: DICE ROLL and if statements
This is a question about how to use RenPy. I move it to RenPy Questions and Announcements.
I also merge the topic. You don't need to make a new thread to ask same question.
Also, please be patient. It hasn't even been one hour since you last ask your question. Everyone have a life out there and not to mention this is an international forum.
I also merge the topic. You don't need to make a new thread to ask same question.
Also, please be patient. It hasn't even been one hour since you last ask your question. Everyone have a life out there and not to mention this is an international forum.
"Double the princesses, quadruple the fun!" - Haken Browning (SRW-OG Endless Frontier)
DeviantArt Account
MoeToMecha Blog (under construction)
Lolicondria Blog (under construction) <- NSFW
DeviantArt Account
MoeToMecha Blog (under construction)
Lolicondria Blog (under construction) <- NSFW
-
- Regular
- Posts: 60
- Joined: Sat Jan 04, 2014 12:52 am
- Location: Canada
- Contact:
Re: Dice roll #2
Something I've used in the past:Timberduck wrote:I am trying to get Dice roll to work
my problem is displaying the roll.
I have spent a few hours already and I am just about to defenestrate my computer into my monitor.
just need an answer.
\m/Timberduck\m/
Code: Select all
def dice(value, limit=100, show=True):
'''Returns True if value is <= a random integer between 1 and limit.
If limit is 100, this means that a value of 60 has a 60% chance for True
'''
number = random.randint(1, limit)
if number <= value:
result = True
else:
result = False
if config.developer and show:
renpy.notify(u"Resulted in %d from %d, limit - %d, and result - %s." % (number, limit, value, result))
return result
Code: Select all
def dice(value):
"""Randomly generated percentage chance to return a bool"""
return (value / 100.0) > random.random()
-
- Regular
- Posts: 60
- Joined: Sat Jan 04, 2014 12:52 am
- Location: Canada
- Contact:
Re: DICE ROLL and if statements
Thanks for your help just one last thing
expected statement.
def dice(value):
^
anyway to cure this ?
expected statement.
def dice(value):
^
anyway to cure this ?
Re: DICE ROLL and if statements
Oh, it's python, you have to put this in init python:Timberduck wrote:Thanks for your help just one last thing
expected statement.
def dice(value):
^
anyway to cure this ?
Without showing results:
Code: Select all
init -10 python:
def dice(value):
"""Randomly generated percentage chance to return a bool"""
return (value / 100.0) > random.random()
Who is online
Users browsing this forum: Bing [Bot], Semrush [Bot], Sugar_and_rice, voluorem