Ren'Py variables

monkeyposter_7

Thirsty for my Guest
Game Developer
Nov 23, 2018
330
1,181
I'm having a problem where the variable don't seem to matter.

I have 2 options defined:
default jenna_like = 50
default jenna_lust = 50

And depending on the amount it accumulates it will affect dialogue and other stuff

So now im testing it and the "lust" is unchanged but it still picked the "lust" dialog, instead of "like"

here is the code in the game wher this happends
Code:
    if jenna_lust == 52:
        jump jennalust1
    if jenna_like == 50:
        jump jennalike1
[code]

so the lust is 50 but it "jumps" to label jennalust1 anyway

maybe i need more commands in this part?
 

Epadder

Programmer
Game Developer
Oct 25, 2016
568
1,064
I mean the structure should work if your indentation is right... although it would be better to do if/elif/else for your test.

I wrote a test scenario to double check the code provided.

Python:
default c_lust = 50
default c_like = 50

label start:
    "What will happen?"
    if c_lust == 52:
        jump c_highlustOne
    elif c_like == 50:
        jump c_highlikeOne
    else:
        "Failed Tests"
    

label fallingthrough:
    "I didn't like either option so I fell through."
    return

label c_highlustOne:
    "Oh aren't you naughty."
    return

label c_highlikeOne:
    "Not feeling that naughty."

return
 
  • Like
Reactions: monkeyposter_7

Saki_Sliz

Well-Known Member
May 3, 2018
1,403
1,011
Can you debug? As in, can you make the game print out the value of lust to a text box or something, doing this before and inside the if statement to see if the value is indeed still 50.

also not sure, but should it be >= instead of ==, that way the option is still available if the lust goes beyond the threshold value.
 

Epadder

Programmer
Game Developer
Oct 25, 2016
568
1,064
With Shift+D you can go to 'variable viewer' which lists all current variables and their values (unless the variable is in an object then you get the memory address of the object).

If you change my example like this:
Python:
label start:
    "What will happen? Current Lust is [c_lust] and Current Like is [c_like]."
    if c_lust == 52:
        jump c_highlustOne
    elif c_like == 50:
        jump c_highlikeOne
    else:
        "Failed Tests"
The [] brackets around a variable name will take the value and translate it to a string.
 

Saki_Sliz

Well-Known Member
May 3, 2018
1,403
1,011
Oh, that's a neat feature to have, I think unity has something similar, but a pain in the ass and harder to find.
 

79flavors

Well-Known Member
Respected User
Jun 14, 2018
1,608
2,256
Good suggestions and I suspect the display of [c_lust] / [c_like] is going to solve it. Either by displaying them in a dialogue... or using the developer menu / variable viewer (SHIFT+D) to see the actual values.

I'm going to guess the problem doesn't lie in your value checks.. but something about where you are changing the values themselves. (so basically the code you haven't shown here).
Imagine you add +2 to lust. If the value went from 51 straight to 53... it would never be equal to 52. Maybe it's something like that.

One thing I will add is that where you are increasing/decreasing values, it's generally better to check for value being "greater than or equal to" (>=) or "less than or equal to" (<=) than it is to check for exact matches (==). i.e. You are checking for 52... but maybe the value is 51 or 53.

Something like:
Python:
label start:
    "What will happen? Current Lust is [c_lust] and Current Like is [c_like]."
    if c_lust >= 52:
        jump c_highlustOne
    elif c_like >= 50:
        jump c_highlikeOne
    else:
        "Failed Tests"
Next up...

Depending on how you are treating affection and lust within your game... maybe you'd be better checking one against the other, rather than arbitrary values. So if you've picked mostly lust choices... you'll go down the lust route... otherwise...

Something like:
Python:
    if c_lust >= c_like:
        jump c_lust_route
    else:
        jump c_like_route

Kind of off topic... but...
(Only applies if you're writing a VN style game... ignore this is you're using open-world style gameplay).


I have to admit, I dislike these kind of affection/lust tracking solutions. They are great if you're following a walkthrough, but as a game author you end up writing two or three separate games into a single game. (The "lust" game, the "love" game and the "neither" game). And whilst meaningful choices do make games better, I think first time developers tend to write only the one "main" route and slot the other routes into the game because they need to rather than actually wanting to.
I'm generalizing of course... maybe this doesn't apply to you. Maybe you've thought it all out and the game won't have . But if you've seen "love/lust" in other games and are just adding it because you liked the idea... maybe consider NOT doing it just yet.
For a first game, I'd be thinking about writing a single route through your story... with previous choices changing one or two lines of dialogue from time to time.
Just a personal opinion of course... It's your game... write it how you like.
 

monkeyposter_7

Thirsty for my Guest
Game Developer
Nov 23, 2018
330
1,181
I have to admit, I dislike these kind of affection/lust tracking solutions. They are great if you're following a walkthrough, but as a game author you end up writing two or three separate games into a single game. (The "lust" game, the "love" game and the "neither" game). And whilst meaningful choices do make games better, I think first time developers tend to write only the one "main" route and slot the other routes into the game because they need to rather than actually wanting to.
I'm generalizing of course... maybe this doesn't apply to you. Maybe you've thought it all out and the game won't have . But if you've seen "love/lust" in other games and are just adding it because you liked the idea... maybe consider NOT doing it just yet.
For a first game, I'd be thinking about writing a single route through your story... with previous choices changing one or two lines of dialogue from time to time.
Just a personal opinion of course... It's your game... write it how you like.
My idea was having this "like" and "lust" factors with each girl, along with few more things that will impact the story in later episodes more and more. And few endings.
Like money will not lead to end game, but u might miss out on a scene if u need money at that point and u left your credit card at home or something like that
Then u have alcohol, that will impact the story and your behaviour. U might not be able to make a "good" choice in some scenes, some girls might like u more/less etc
Certain choices as "reject her" and such will end a girls path or u miss out on a scene

For example, i already wrote the second episode, and "if jenna_lust" is below a certain point u didn't do a ceratin "defined" thing previously, u miss out on a masturbation scene.

I know that some people find it pointless to work and render the scene and u don't even see it depending on the choices, but I think it's adds a replay value to the game. Many people want to go back and check out what happens otherwise.
And i really enjoy that in games and VN's.

(back on topic)
And thanks everyone for the suggestions. I'll be testing this out today and hopefully release the full first episode. Renders are done, just testing the code and few other stuff.
I think the +2 "lust" is the problem, i didn't know it doesn't read 52 if u went from 51 to 53.
Because the "if" thing works in few cases, and in others it doesn't, but i didn't do anything different.
So i will test this first and see where it leads me, hopefully somewhere good lol
 

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Donor
Respected User
Jun 10, 2017
10,971
16,228
With Shift+D you can go to 'variable viewer' which lists all current variables and their values (unless the variable is in an object then you get the memory address of the object).
For game testing, the watch/unwatch console commands are probably better.
Shift + o to open the console, then :
Code:
watch c_lust
watch c_love
Like the value will be displayed all the time, and updated in real time, you'll not only be able to validate that they are what you expect (which isn't apparently the case here), but also be able to find where the value have "unexpectedly" changed.
It also help track basic errors like by example :
Code:
myVar =- 1
myVar =+ 1
 

Epadder

Programmer
Game Developer
Oct 25, 2016
568
1,064
For game testing, the watch/unwatch console commands are probably better.
Shift + o to open the console, then :
Code:
watch c_lust
watch c_love
Like the value will be displayed all the time, and updated in real time, you'll not only be able to validate that they are what you expect (which isn't apparently the case here), but also be able to find where the value have "unexpectedly" changed.
It also help track basic errors like by example :
Code:
myVar =- 1
myVar =+ 1
I forgot that exists, when I was first looking for something like that I found a that was posted on the official Ren'py forums in the cookbook. It seems to work okay, but the functionality has already been implemented officially with "watch"... when it was first made maybe that wasn't the case? :unsure:
 

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Donor
Respected User
Jun 10, 2017
10,971
16,228
It seems to work okay, but the functionality has already been implemented officially with "watch"... when it was first made maybe that wasn't the case? :unsure:
Don't really remember, but for sure the watch command is now fully working and efficiently ; even if I think about extending it a little.