Ren'Py Stat recall

Mescalino

Active Member
Aug 20, 2017
945
6,700
With the following statement:
if love == 2:

I ask if the stat Love is 2

But how do i ask if its 2 or up (or below)

i tried
if love >= 2:
but that didnt seem to work. Its probably simple but i cant find it in the wiki.
 

Papa Ernie

Squirrel!?
Uploader
Donor
Dec 4, 2016
12,333
48,131
Did you create the variable first?

example:
$ love = 0

PS Show the full event so we can see where you went wrong.
 
Last edited:

Mescalino

Active Member
Aug 20, 2017
945
6,700
Well its quite a bit of code so i will give the short version:
Code:
default friendship = 0
default love = 0
default lust = 0
Thats in my mechanic.rpy

Then during convo
Code:
mc "blal bla bla you look amazing"
$ love += 1

mc "bla bla bla i love you"
$ love += 2
Then i want to check if he has a certain amount of love points`
Code:
if love >= 2:
 "You give her a kiss"
else
 "You run away scared"
the point system works. and i can check a value wit if love == 2
But what if he has 3 points, the statement would be false and go to the else part.
i want to give the player a bit of freedom so he/she doesn't allways needs to have the max points available.
 

Papa Ernie

Squirrel!?
Uploader
Donor
Dec 4, 2016
12,333
48,131
If the value is 3, then your statement would be TRUE. 3 >= 2

>= means greater than or equal to
 
Last edited:

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Donor
Respected User
Jun 10, 2017
10,975
16,230
Code:
if love >= 2:
 "You give her a kiss"
else
 "You run away scared"
If it's a strict copy of your actual code, then you missed the ':' after the else. That's the only error I can see, but normally ren'py shouldn't let you run with it :/
Well, to be fair there's another possible error, the fact that you've defined the variable in one store, and try to use it in another. But I don't think that you've gone this far, so I exclude it.

Now, try this :
Code:
if 1 < love:
 "You give her a kiss"
else:
 "You run away scared"
It's exactly the same than your "if love >= 2:" but who know, perhaps that it will work.

If it still don't work, try this :
Code:
"Expected love is [store.love], used love is [love]"
if 1 < love:
 "You give her a kiss"
else:
 "You run away scared"
You'll know the value you think you test (the variable "love" from the default store) and the value actually tested (the variable "love" from the actual store). If there's a difference, then here's the error and try to understand why you have two stores.
In the same time, you'll know... well, the value. So you'll be sure that it's over 2. If it's not, then here's the error, and search why the value isn't incremented correctly.
And if the value is over 2 and it still not work... You'll need to reduce the code to the part which don't work and post-it. It's the only way to help.
 

Belle

Developer of Supermodel & Long Live the Princess
Game Developer
Sep 25, 2017
3,189
10,603
Now, try this :
Code:
if 1 < love:
 "You give her a kiss"
else:
 "You run away scared"
It's exactly the same than your "if love >= 2:" but who know, perhaps that it will work.
I would never advise anyone to put the constant on the left side like that during a conditional check. It's so non-standard that even a seasoned developer will get thrown off when reading it. "if love >= 2" works and is the correct answer to Mescalino's question. If there is still a problem getting this to work, then the error lies elsewhere. It's not the if-statement that is faulty. I would recommend looking over the variable assignments to see if the "love" variable is at the level you think it is when you do that check. Print it to the dialogue like shown in the post above.
 

Corrupting

New Member
Aug 18, 2017
1
0
Check if you're defining love in init somewhere. If so, its a constant that can't be changed (remove that line and use default)
 

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Donor
Respected User
Jun 10, 2017
10,975
16,230
It's so non-standard that even a seasoned developer will get thrown off when reading it.
Sorry, but Yoda Conditions aren't "non-standard". It's a question of writing style more than validity, and a lot of professionals use it ; initially for bug avoiding purpose, then by habit.
Indeed the said bug is impossible in Python, since you can't have assignation in condition. Still PyLint see Yoda Conditions as just a convention check and not an error. Plus the fact that "2 < value < 5" is a valid condition in Python, which lead some python addicts to use Yoda Conditions as an opened door for future interval checking, while style using standard notation most of the time.

This said, the purpose of my answer wasn't to teach good practices, nor even practices. It was just to help and in the same time show an example of debugging process. First eliminate any syntax problem by using, temporarily, an alternate syntax...
 

Mescalino

Active Member
Aug 20, 2017
945
6,700
Thanks for all the help guys. I have been incredibly busy and had some creative buzz so i had to do some writing.
Also there is a standard "stat screen" available in my novel that shows teh statistics. I will test this as soon as im able. Also i will post the results here.