"Affection points" variable help

Discuss how to use the Ren'Py engine to create visual novels and story-based games. New releases are announced in this section.
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.
Post Reply
Message
Author
User avatar
ForeverAScone
Newbie
Posts: 20
Joined: Sat May 23, 2020 8:08 pm
Projects: Working title to do with string theory. Got any got string puns/phrases? Please do tell me, lol.
Location: Under your bed
Contact:

"Affection points" variable help

#1 Post by ForeverAScone » Sun Aug 16, 2020 5:18 pm

Hi, I'm doing a test and trying to make it so if you pick a certain option in a menu , you will gain an "affection_point" for each answer in the character's favour. I defined the variable at the beginning to "define affection_points = 0" and this is my first menu that comes up:

Code: Select all

label affection_test:
    c "Do you like cats?"
    menu:
        "Yes, I love them.":
            $ affection_points=+1
        "No, they are stinky.":
            pass
    
    if affection_points==1:
        c "Yas, you have great taste in pets."
    else:
        c "Wow, rude."
This menu does work correctly. However, when I continue and add more options, I wanted to keep adding up the points, but it seems to not be adding them up.

Code: Select all

 c "So, what do you think of my new hairstyle?"
    menu:
        "Uh, it's... interesting... ^^":
            pass
        "It's totally rockin'.":
            $ affection_points=+1
    c "Oh, okay."
    "(I should say something else to gain his affection.)"
    menu:
        "What's cookin', good lookin'?":
            $ affection_points=+1
        "Uh, okay, bye.":
            pass
            
    if affection_points==3:
        c "Wow, you really get me, man."
    if affection_points==2:
        c "Oh, okay, see ya around. ^^"
    if affection_points==1:
        c "Uh, okay..."
    if affection_points==0:
        c "Get outta here."
This always ends up with the outcome for "if affection_points==1" ("Uh, okay...") no matter which options I am chosing (besides always chosing the first option about liking cats). So what am I doing wrong here? Also, how do I write a range of numbers, like "if affection_points==0-1" or ">1"? I tried those but it says it is invalid syntax.
Hey, and another question, when the user saves and quits the game, does the game remember how many of this variable they will have earned, or does it reset back to 0 when the game is quit? Thank you for the help!
Your average noob here. Howdydoo

ichfly
Newbie
Posts: 14
Joined: Sat Aug 15, 2020 12:40 pm
Contact:

Re: "Affection points" variable help

#2 Post by ichfly » Sun Aug 16, 2020 5:42 pm

You set affection_points to +1 what you want to do is affection_points+=1 + and = are swapped
you can use multiple conditions with or -->

Code: Select all

affection_points==1 or affection_points==2
or you can define a list and check if it is in the list -->

Code: Select all

affection_points in (1,2,3,4)
if you don't save it it fall back to the default value

User avatar
rayminator
Miko-Class Veteran
Posts: 508
Joined: Fri Feb 09, 2018 12:05 am
Projects: Redoing games to fix spelling mistakes other companys that don't care
Location: Canada
Contact:

Re: "Affection points" variable help

#3 Post by rayminator » Sun Aug 16, 2020 10:39 pm

this is wrong

Code: Select all

$ affection_points=+1
the plus sign should come before the equal sign it should be like this

Code: Select all

$ affection_points+=1
when I try to help someone I point them into 2 direction what's right and wrong so they can learn how to

User avatar
trooper6
Lemma-Class Veteran
Posts: 3712
Joined: Sat Jul 09, 2011 10:33 pm
Projects: A Close Shave
Location: Medford, MA
Contact:

Re: "Affection points" variable help

#4 Post by trooper6 » Mon Aug 17, 2020 11:01 pm

ForeverAScone wrote:
Sun Aug 16, 2020 5:18 pm
Hi, I'm doing a test and trying to make it so if you pick a certain option in a menu , you will gain an "affection_point" for each answer in the character's favour. I defined the variable at the beginning to "define affection_points = 0" and this is my first menu that comes up:
Note: You should be declaring this variable like so:

Code: Select all

default affection_points = 0
"define" is for variables that will not change.
"default" is for variables that will change.
A Close Shave:
*Last Thing Done (Aug 17): Finished coding emotions and camera for 4/10 main labels.
*Currently Doing: Coding of emotions and camera for the labels--On 5/10
*First Next thing to do: Code in all CG and special animation stuff
*Next Next thing to do: Set up film animation
*Other Thing to Do: Do SFX and Score (maybe think about eye blinks?)
Check out My Clock Cookbook Recipe: http://lemmasoft.renai.us/forums/viewto ... 51&t=21978

User avatar
ForeverAScone
Newbie
Posts: 20
Joined: Sat May 23, 2020 8:08 pm
Projects: Working title to do with string theory. Got any got string puns/phrases? Please do tell me, lol.
Location: Under your bed
Contact:

Re: "Affection points" variable help

#5 Post by ForeverAScone » Fri Sep 04, 2020 9:02 pm

Ahh, thanks for the clarification everyone ^^ I will give it a go.
Your average noob here. Howdydoo

Post Reply

Who is online

Users browsing this forum: hell_oh_world