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.
-
chesarty
- Regular
- Posts: 116
- Joined: Sat Aug 25, 2018 3:07 am
- Completed: 0
-
Contact:
#1
Post
by chesarty » Mon Aug 19, 2019 4:35 am
I've been following this tutorial:
viewtopic.php?f=51&t=22817 in order to get myself an easy affection points system. (I decided to make a new thread for this since the original post was from 2013...)
It seems like a really simple thing to implement, but for some reason the points do not update for me.
Code: Select all
label start:
$atticus_aff = 0
$rhys_aff = 0
$damon_aff = 0
$enzo_aff = 0
Code: Select all
menu:
"...Yes.":
$enzo_aff +=10
jump yes_im_lost
"What? No!":
$enzo_aff -=10
jump no_im_not_lost
After these codes, I have this little line of dialogue at the end of the scene just so I can test this feature out.
Code: Select all
"Enzo now has %(enzo_aff)d affection points towards you."
Naturally, if the code worked, it would say "Enzo now has 10/-10 affection points for you" but now it just says 0 no matter what I pick. How to fix this?

Last edited by
chesarty on Wed Aug 21, 2019 12:00 am, edited 2 times in total.
-
Angelo Seraphim
- Regular
- Posts: 32
- Joined: Tue May 21, 2019 8:00 am
- Completed: Enamored Risks (NaNoReNo 2020)
- Projects: 616 Charagma
- Organization: GLSUoA
- Deviantart: glsuoa
- itch: glsuoa
- Location: London, UK
- Discord: Just A Concept#9599
-
Contact:
#2
Post
by Angelo Seraphim » Mon Aug 19, 2019 4:55 am
I think what you want is:
Code: Select all
# Declare your variables first. That's what, I think, you're missing.
default atticus_aff = 0
default rhys_aff = 0
default damon_aff = 0
default enzo_aff = 0
label start:
$ atticus_aff = 0
$ rhys_aff = 0
$ damon_aff = 0
$ enzo_aff = 0
menu:
"...Yes.":
$ enzo_aff += 10
jump yes_im_lost
"What? No!":
$ enzo_aff -= 10
jump no_im_not_lost
# content after menu
-
chesarty
- Regular
- Posts: 116
- Joined: Sat Aug 25, 2018 3:07 am
- Completed: 0
-
Contact:
#3
Post
by chesarty » Mon Aug 19, 2019 5:18 am
Angelo Seraphim wrote: ↑Mon Aug 19, 2019 4:55 am
I think what you want is:
Code: Select all
# Declare your variables first. That's what, I think, you're missing.
default atticus_aff = 0
default rhys_aff = 0
default damon_aff = 0
default enzo_aff = 0
label start:
$ atticus_aff = 0
$ rhys_aff = 0
$ damon_aff = 0
$ enzo_aff = 0
menu:
"...Yes.":
$ enzo_aff += 10
jump yes_im_lost
"What? No!":
$ enzo_aff -= 10
jump no_im_not_lost
# content after menu
That still doesn't work, unfortunately.

-
isobellesophia
- Miko-Class Veteran
- Posts: 979
- Joined: Mon Jan 07, 2019 2:55 am
- Completed: None
- Projects: Maddox and Friends! (AI Teacher friend), Friendly Universities! (Soon)
- Organization: Friendly Teachers series
- Deviantart: SophBelle
- itch: Child Creation
- Location: Philippines, Mindanao
-
Contact:
#4
Post
by isobellesophia » Mon Aug 19, 2019 6:29 am
chesarty wrote: ↑Mon Aug 19, 2019 5:18 am
Angelo Seraphim wrote: ↑Mon Aug 19, 2019 4:55 am
I think what you want is:
Code: Select all
# Declare your variables first. That's what, I think, you're missing.
default atticus_aff = 0
default rhys_aff = 0
default damon_aff = 0
default enzo_aff = 0
label start:
$ atticus_aff = 0
$ rhys_aff = 0
$ damon_aff = 0
$ enzo_aff = 0
menu:
"...Yes.":
$ enzo_aff += 10
jump yes_im_lost
"What? No!":
$ enzo_aff -= 10
jump no_im_not_lost
# content after menu
That still doesn't work, unfortunately.
Those $ should be before label start. Replace it the top of the label start and try if it is works.
Or if not, try removing those, and let the default stay.
I am a friendly user, please respect and have a good day.

-
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:
#5
Post
by namastaii » Mon Aug 19, 2019 11:55 am
You don't need the $ at all unless you're about to change them. Leave the default variables that are defined before the game stars, remove the second group because there is no point for them since they're already at 0 with the default statement.
-
isobellesophia
- Miko-Class Veteran
- Posts: 979
- Joined: Mon Jan 07, 2019 2:55 am
- Completed: None
- Projects: Maddox and Friends! (AI Teacher friend), Friendly Universities! (Soon)
- Organization: Friendly Teachers series
- Deviantart: SophBelle
- itch: Child Creation
- Location: Philippines, Mindanao
-
Contact:
#6
Post
by isobellesophia » Mon Aug 19, 2019 12:06 pm
Also, $ is a permanent define, while default is not. So you need default instead.
I am a friendly user, please respect and have a good day.

-
Per K Grok
- Miko-Class Veteran
- Posts: 882
- Joined: Fri May 18, 2018 1:02 am
- Completed: the Ghost Pilot, Sea of Lost Ships, Bubbles and the Pterodactyls, Defenders of Adacan Part 1-3, the Phantom Flyer
- itch: per-k-grok
- Location: Sverige
-
Contact:
#7
Post
by Per K Grok » Mon Aug 19, 2019 4:45 pm
chesarty wrote: ↑Mon Aug 19, 2019 5:18 am
-----
That still doesn't work, unfortunately.
I set your code up like this and it runs without problem for me.
It is set up so you can run it over and over again, testing both alternatives.
Code: Select all
default atticus_aff = 0
default rhys_aff = 0
default damon_aff = 0
default enzo_aff = 0
label start:
menu:
"...Yes.":
$ enzo_aff += 10
jump yes_im_lost
"What? No!":
$ enzo_aff -= 10
jump no_im_not_lost
label yes_im_lost:
"Enzo now has %(enzo_aff)d affection points towards you."
$ enzo_aff = 0
jump start
label no_im_not_lost:
"Enzo now has %(enzo_aff)d affection points towards you."
$ enzo_aff = 0
jump start
-
chesarty
- Regular
- Posts: 116
- Joined: Sat Aug 25, 2018 3:07 am
- Completed: 0
-
Contact:
#8
Post
by chesarty » Tue Aug 20, 2019 3:48 am
namastaii wrote: ↑Mon Aug 19, 2019 11:55 am
You don't need the $ at all unless you're about to change them. Leave the default variables that are defined before the game stars, remove the second group because there is no point for them since they're already at 0 with the default statement.
I deleted the $ stuff but it still doesn't work, ehhhh D:
-
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:
#9
Post
by namastaii » Tue Aug 20, 2019 11:09 am
Okay, try $ enzo_aff + 10 instead of +=
-
chesarty
- Regular
- Posts: 116
- Joined: Sat Aug 25, 2018 3:07 am
- Completed: 0
-
Contact:
#10
Post
by chesarty » Tue Aug 20, 2019 11:59 pm
Per K Grok wrote: ↑Mon Aug 19, 2019 4:45 pm
chesarty wrote: ↑Mon Aug 19, 2019 5:18 am
-----
That still doesn't work, unfortunately.
I set your code up like this and it runs without problem for me.
It is set up so you can run it over and over again, testing both alternatives.
Code: Select all
default atticus_aff = 0
default rhys_aff = 0
default damon_aff = 0
default enzo_aff = 0
label start:
menu:
"...Yes.":
$ enzo_aff += 10
jump yes_im_lost
"What? No!":
$ enzo_aff -= 10
jump no_im_not_lost
label yes_im_lost:
"Enzo now has %(enzo_aff)d affection points towards you."
$ enzo_aff = 0
jump start
label no_im_not_lost:
"Enzo now has %(enzo_aff)d affection points towards you."
$ enzo_aff = 0
jump start
thank you! it runs alright now

it's confusing to me how that one worked and mine didn't since it looks identical to me, but i'm very glad to have it working. thanks again!
Users browsing this forum: Bing [Bot]