Hello there once again.
This time I need help figuring out exactly how you go about making alternate routes depending on a numeric value that has been increasing or decreasing depending on previous actions. My attempts at doing so have resulted in nothing ideal, to the say least.
Example of what I need is:
Let's say...
-Anything 25 or greater goes on this path.
-Anything equal to or less than (or I suppose greater than) -25, goes on this path.
-Anything between 25 and -25 goes on this path.
That's essentially what I am trying to do. However, regardless of values, it seems to want to go on wrong paths. Any help on the code necessary for the above would be really helpful. I assume I am just using Or and And statement incorrectly but I could be wrong.
Thanks in advance.
Numeric Options [Solved]
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.
Numeric Options [Solved]
Last edited by Skiegh on Sun Apr 21, 2013 12:01 pm, edited 1 time in total.
Re: Numeric Options
Try using if statements:
Code: Select all
if myvalue >= 25:
jump path1
elif myvalue <= -25:
jump path2
else:
jump path3
Re: Numeric Options [Solved]
That had the desired effect, thank you. (I was close, I just didn't know about that elif statement, which I assume is short for ElseIf. Useful to know!)kankan wrote:Try using if statements:Code: Select all
if myvalue >= 25: jump path1 elif myvalue <= -25: jump path2 else: jump path3
Wouldn't mind knowing how to actually use an And statement for a similar solution just to know for future reference however. Say instead of just the else statement for the third option, it wanted to dictate exactly that you were above -25 and below 25, how would I code that exactly? I like to know these things so I don't have to pry for more information.
Re: Numeric Options [Solved]
Yeah, Python's elseif clause is a little weird... If you want the third option to be both of the previous two, you'd have to put that as the first if (otherwise Python will just see that the variable fits the first, more general condition and ignore the specific one you want). So something like this:
The "and" statement will work pretty much as you expect it to. Same goes for "or" and "not."
Code: Select all
if a >= 25 and b <= -25:
jump somewhere
elif a >= 25:
jump somewhereelse
elif b <= -25:
jump anotherplace
else:
jump lastresort
Who is online
Users browsing this forum: Ocelot