Adding variables together
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.
Adding variables together
Hey folks,
I'm having what is probably a very simple to fix issue, but I can't quite figure it out. I'm trying to create a variable which is equal to the value of five other variables added together. I want variable 'x' to be equal to the sum of variables a, b, c, d, and e. So I write the code like this:
$ x == a + b + c + d + e
For some reason, this always seems to give me a value of 0 for x no matter what the other variables are. What am I doing wrong here?
I'm having what is probably a very simple to fix issue, but I can't quite figure it out. I'm trying to create a variable which is equal to the value of five other variables added together. I want variable 'x' to be equal to the sum of variables a, b, c, d, and e. So I write the code like this:
$ x == a + b + c + d + e
For some reason, this always seems to give me a value of 0 for x no matter what the other variables are. What am I doing wrong here?
-
apricotorange
- Veteran
- Posts: 479
- Joined: Tue Jun 05, 2012 2:01 am
- Contact:
Re: Adding variables together
Two equal signs are only used for comparisons, only one is necessary for assignment
My avatar art is a freebie by SilverHyena. Thanks a lot!
Re: Adding variables together
That fixed it. Thank you, and sorry for missing the tag.
- fantanoice
- Newbie
- Posts: 8
- Joined: Sun Sep 16, 2012 8:23 am
- Contact:
Re: Adding variables together
Yep, basically '==' is for comparing if something 'is equal to' something else. '=' is for assigning a value to something.
Eg: Comparision:
if(something == true)
do stuff
('Do stuff' is only done when 'something' is true).
Eg: Assignment:
something = 1 + 2
('Something' now has the value of '3').
Did that make sense?
Eg: Comparision:
if(something == true)
do stuff
('Do stuff' is only done when 'something' is true).
Eg: Assignment:
something = 1 + 2
('Something' now has the value of '3').
Did that make sense?