Conditional statement not working right
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.
-
- Newbie
- Posts: 19
- Joined: Sun Apr 12, 2015 2:04 am
- Contact:
Conditional statement not working right
SOLVED. I'm a space case.
Last edited by doodlemancy on Tue Dec 29, 2015 8:45 pm, edited 3 times in total.
Re: Conditional statement not working right
I think your only problem is the fact that the menu should be indented so that it's in the same indent block as the stuff within the else statement.
Code: Select all
label killtime:
if things_remaining == 0:
jump storyprogress
else:
"It looks like I've still got some time to kill."
menu:
"Do thing 1." if thing1_available == "True":
$ thing1_available = "False"
$ things_remaining =- 1
jump thing1doing
"Do thing 2." if thing2_available == "True":
$ thing2_available = "False"
$ things_remaining =- 1
jump thing2doing
"Do thing 3." if thing3_available == "True":
$ thing3_available = "False"
$ things_remaining =- 1
jump thing3doing
Re: Conditional statement not working right
A few things.
1. Minor errors in indentation (e.g., the else is indented one extra space) -- fix those. (I realize they may be the result of editing the code to put up on the forum, but always good to double check anyway.) The indentation of the menu doesn't matter in this case, because if you jump to storyprogress, you'll never get to the menu anyway.
2. While what you have does work, why are you using the strings "True"/"False" rather than the boolean values True/False?
seems much preferable to me.
3. The reason your loop doesn't work is that you wrote
$ things_remaining =- 1 (wrong)
instead of
$ things_remaining -= 1 (right)
The first statement sets things_remaining to -1 (therefore, things_remaining == 0 is never triggered).
You can check the value of variables, by the way, by pressing shift+o to open the console and typing watch variable (in this case, watch things_remaining).
1. Minor errors in indentation (e.g., the else is indented one extra space) -- fix those. (I realize they may be the result of editing the code to put up on the forum, but always good to double check anyway.) The indentation of the menu doesn't matter in this case, because if you jump to storyprogress, you'll never get to the menu anyway.
2. While what you have does work, why are you using the strings "True"/"False" rather than the boolean values True/False?
Code: Select all
$ thing1_available = True
menu:
"Do thing 1." if thing1_available:
$ thing1_available = False
3. The reason your loop doesn't work is that you wrote
$ things_remaining =- 1 (wrong)
instead of
$ things_remaining -= 1 (right)
The first statement sets things_remaining to -1 (therefore, things_remaining == 0 is never triggered).
You can check the value of variables, by the way, by pressing shift+o to open the console and typing watch variable (in this case, watch things_remaining).
Last edited by philat on Tue Dec 29, 2015 8:45 pm, edited 1 time in total.
-
- Newbie
- Posts: 19
- Joined: Sun Apr 12, 2015 2:04 am
- Contact:
Re: Conditional statement not working right
D'oh. That's just me spacing out.philat wrote:While what you have does work, why are you using the strings "True"/"False" rather than the boolean values True/False?
GAAAAH THIS WAS IT!! THIS WAS IT!! BUT WHY? I had previously had it the right way before, and Ren'py kept yelling at me about it and telling me it was wrong. I'm so confused. Thank you. I'm going to lie down now.philat wrote:The reason your loop doesn't work is that you wrote
$ things_remaining =- 1 (wrong)
instead of
$ things_remaining -= 1 (right)
Who is online
Users browsing this forum: Google [Bot]