"IF" statement issue.(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.
-
LeperWeaboo
- Newbie
- Posts: 2
- Joined: Mon Jan 18, 2016 10:57 pm
- Contact:
"IF" statement issue.(Solved)
Hello there , I need some help so that my "if" statements dont overlap on one another.More info with the images.Thanks.
The ignore button works too , but that isnt really a fix.
The ignore button works too , but that isnt really a fix.
- Attachments
-
- Entry.
- B.jpg (2.38 KiB) Viewed 604 times
-
- Entry.
- A.jpg (2.68 KiB) Viewed 604 times
Last edited by LeperWeaboo on Tue Jan 19, 2016 2:17 pm, edited 2 times in total.
- namastaii
- Eileen-Class Veteran
- Posts: 1350
- Joined: Mon Feb 02, 2015 8:35 pm
- Projects: Template Maker for Ren'Py, What Life
- Github: lunalucid
- Skype: Discord: lunalucid#1991
- Soundcloud: LunaLucidMusic
- itch: lunalucid
- Location: USA
- Contact:
Re: "IF" statement issue.
Could you show more of the code?
Re: "IF" statement issue.
You're missing a colon on your penultimate line:
Also, the error message you're getting tells you the problem you're having: The variable rpe is not defined before line 285 has been run.
Where you have...
You need to ensure that rpe is defined before it, for example:
Always check your code line that causes the exception, and work your way backwards from that.
Code: Select all
if gift == tortoise :Where you have...
Code: Select all
if rpe == "queene" :Code: Select all
rpe == ""
if rpe == "queene" :
If we are what we repeatedly do, then good coding is not an act, but a habit
Re: "IF" statement issue.
Use:
You can put that anywhere and it'll always get loaded into the code, even in a saved game (although it's best to keep these where you can find them). It's relatively new, apparently. But yeah, if you try to use a variable before defining it, errors.
As to your second problem, I'm not exactly sure why that would give unintended results, it should only spit back one of those things at a time, you are missing a ":" after "tortoise, which would cause some issues. Also, you might want to change the "if"s after the first one to "elif"s. In this case it shouldn't have a different result, but it is more efficient, since in the current form, it checks the first one, then even if that one is right, it checks the next, and the next, and so on. If you use elif statements instead, then if the second one passes, it forgets about the third, forth, fifth, etc. and skips to the end of that chain and on to the next thing. Sometimes the checks can be several things and you'd want to check each possibility, but in this case it seems like a single variable with a single possible truth, so making the check as efficient as possible would be nice.
Code: Select all
default rpe = "whatever you want the default to be"
As to your second problem, I'm not exactly sure why that would give unintended results, it should only spit back one of those things at a time, you are missing a ":" after "tortoise, which would cause some issues. Also, you might want to change the "if"s after the first one to "elif"s. In this case it shouldn't have a different result, but it is more efficient, since in the current form, it checks the first one, then even if that one is right, it checks the next, and the next, and so on. If you use elif statements instead, then if the second one passes, it forgets about the third, forth, fifth, etc. and skips to the end of that chain and on to the next thing. Sometimes the checks can be several things and you'd want to check each possibility, but in this case it seems like a single variable with a single possible truth, so making the check as efficient as possible would be nice.
-
LeperWeaboo
- Newbie
- Posts: 2
- Joined: Mon Jan 18, 2016 10:57 pm
- Contact:
Re: "IF" statement issue.
Hesus thanks for all the info.
Answering all the questions :
"if gift == tortoise : "I did place the two dots/colon at the end since the script wouldnt work without it.That was just a screen shot taken from here
http://renpy.org/wiki/renpy/doc/tutoria ... er_Choices which doesnt have it , but that is not the issue.
Ive updated the post with further info on how i defined the actions , which i dont think i did much different from what ive been told so far.The only difference i see is the $ at the start.
Ill try the elif command.
Edit:Nvm , i actually changed the "rpe" at two of them since i thought i can change that too.But now i fixed it , sorry to bother you all for this .
Thank you all,especially Onishion.
Answering all the questions :
"if gift == tortoise : "I did place the two dots/colon at the end since the script wouldnt work without it.That was just a screen shot taken from here
http://renpy.org/wiki/renpy/doc/tutoria ... er_Choices which doesnt have it , but that is not the issue.
Ive updated the post with further info on how i defined the actions , which i dont think i did much different from what ive been told so far.The only difference i see is the $ at the start.
Ill try the elif command.
Edit:Nvm , i actually changed the "rpe" at two of them since i thought i can change that too.But now i fixed it , sorry to bother you all for this .
Thank you all,especially Onishion.
Re: "IF" statement issue.(Solved)
About the $ sign thing, IF you change the variable within a python block, something like
Then you don't need a $. If you put it outside of such a python block, however, which is most of an Renpy game, then you need the $ sign before any line which changes a variable, since that tells Renpy that that line is python code.
Glad you got it working though.
Code: Select all
python:
Variable = 5
Glad you got it working though.
Who is online
Users browsing this forum: Bing [Bot], Google [Bot]