So, in my game I'm trying to make a sort of 'morality' system, based mainly off of lying and manners. So, in menu choices I'll have the 'good' option, a neutral option, and the 'bad' option, with +1 in that field if you choose it. However, it seems that even when you don't choose the option the points still get added, which is wreaking havoc on my NPC reactions. Help?
Sorry if I didn't explain that very well. Thanks in advance!
Problem with variables based on user input
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.
-
- Regular
- Posts: 33
- Joined: Sun Sep 18, 2011 1:36 pm
- Projects: Shaeyu jun Ikkshaelun
- Contact:
- netravelr
- Miko-Class Veteran
- Posts: 504
- Joined: Thu Jan 28, 2010 2:31 am
- Completed: Culina: Hands in the Kitchen, Culina: The Spirit of Cooking, Saving Zoey
- Projects: Love at the Laundromat
- Organization: Lakeview Interactive
- Deviantart: netravelr
- Location: USA
- Contact:
Re: Problem with variables based on user input
So somewhere outside of the scope of the menu (probably at the base part of the game) you'll have a variable of some sort (morality for instance) in which you'd initialize it
when you make a choice but before you jump to another section put and that will increase the amount by 1 and -= 1 will decrease it.
Or do you mean that you have a menu and you don't jump outside of the line that adds the +1?
Code: Select all
morality = 0
Code: Select all
morality += 1
Or do you mean that you have a menu and you don't jump outside of the line that adds the +1?
Technical Designer/Programmer
Game Design Portfolio - Project updates on my Twitter
Experienced in: C/C++/C#, Python, Unreal, Unity, and Flash
_________________
"Space can be very lonely. The greatest adventure is having someone share it with you."
-
- Regular
- Posts: 33
- Joined: Sun Sep 18, 2011 1:36 pm
- Projects: Shaeyu jun Ikkshaelun
- Contact:
Re: Problem with variables based on user input
Let's see, I actually have two variables, 'ruffian' and 'saint'. The 'bad' option adds 1 to the ruffian value, and the 'good' option adds +1 to the saint value. But, would using a count like yours where they're both one and the same be better..? It certainly sounds simpler.
Here's my code for one of the menus:
And I do have the variables declared with the starting value of 0 at the beginning too.
Here's my code for one of the menus:
Code: Select all
menu:
"Destiny? I don't believe in that crap.":
f "I don't believe in destiny. I can make my own path, old man."
$ ruffian += 1
a "You don't have a choice, young woman. You must do this."
"Destiny? Who is he to tell me my destiny?":
f "How would {i}you{/i} know what my destiny is?"
a "Always the skeptic, I see."
"I must follow destiny.":
f "It's my destiny? Then I suppose I should do it."
$ saint += 1
a "I'm glad you see the importance of this."
- netravelr
- Miko-Class Veteran
- Posts: 504
- Joined: Thu Jan 28, 2010 2:31 am
- Completed: Culina: Hands in the Kitchen, Culina: The Spirit of Cooking, Saving Zoey
- Projects: Love at the Laundromat
- Organization: Lakeview Interactive
- Deviantart: netravelr
- Location: USA
- Contact:
Re: Problem with variables based on user input
Yeah if you don't initialize the value then it'll be whatever piece of memory was there in the first place which just happened to be 1 in your case. It's always a good idea to initialize stuff before you use it. Hope I helped!
Technical Designer/Programmer
Game Design Portfolio - Project updates on my Twitter
Experienced in: C/C++/C#, Python, Unreal, Unity, and Flash
_________________
"Space can be very lonely. The greatest adventure is having someone share it with you."
Who is online
Users browsing this forum: Google [Bot], Imperf3kt, voluorem