Attack of the Newbie Question That Has Probably Been Asked A Million Times Before!
When adding and subtracting numeric variables ($ variable +/-= x), how do I get it to +/- a random number within a given range instead of a fixed value?
Likewise, when customizing endings, instead of operating purely on a <, >, = structure, can I get it to access certain endings if a variable falls within a certain range? 'If variable = 12-13 jump A, 14-25 jump B' type of thing?
More on a Helping Me Think Ahead note, is it possible to define endings based on more than one variable? Ex., both variable A and variable B need to fall within a certain range, or two mutually exclusive ranges, to get ending 1, else ending 2?
Thank you ahead of time for the generous newbie coddling. *Cough*
Variable ranges?
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.
Variable ranges?
~Meddle not in the affairs of Dragons, for thou art crunchy and taste good with ketchup.
Okay, I'll take a stab at the easy one.
There are a few different random functions at the very bottom of chapter 7 in the manual, too.
For ranges, I've always used cascading if/elif/else statements (in Python, anyway). Don't know if there's an easier way to do it?
And, for your last question, you can join clauses with "and" and "or" although I've heard there's some complicated behavior in Python. Boolean logic (okay, any kind of logic) isn't my forte, so I've never really gone much past very simple 'and' statements.
(Someone more knowledgeable should be along shortly. And I like your sig!)
Code: Select all
# number between 1 and 10, inclusive (I think)
$ rand_number = renpy.random.randint(1, 10)
$ number += rand_number
# number is now number plus random number
For ranges, I've always used cascading if/elif/else statements (in Python, anyway). Don't know if there's an easier way to do it?
And, for your last question, you can join clauses with "and" and "or" although I've heard there's some complicated behavior in Python. Boolean logic (okay, any kind of logic) isn't my forte, so I've never really gone much past very simple 'and' statements.
Code: Select all
if ending_points == 10 and special_end == True:
"Ending points is equal to 10 and special end is True."
else:
"Either ending_points is less than 10 or special_end is False."
My 2007 NaNo entry: Eidolon
Re: Variable ranges?
I wanted to do something similair myself a while back, sadly the only way to do this is to use > ,< with 'and'Mallamun wrote: Likewise, when customizing endings, instead of operating purely on a <, >, = structure, can I get it to access certain endings if a variable falls within a certain range? 'If variable = 12-13 jump A, 14-25 jump B' type of thing?
for example
Code: Select all
if score > 0 and score < 5:
jump outcomea
if score > 4 and score < 9:
jump outcomeb
Who is online
Users browsing this forum: No registered users