[Solved!] Love meter event with more then one character.

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
Elta
Regular
Posts: 72
Joined: Sun Jun 02, 2019 6:28 pm
Tumblr: limitelta
Deviantart: limitelta
itch: limitelta
Contact:

[Solved!] Love meter event with more then one character.

#1 Post by Elta » Sat Jun 08, 2019 6:16 pm

So at the beginning of the game I set their values:

Code: Select all

$ charA = 0
then I add points along the way:

Code: Select all

$ charA += 5
Finally I can create events based on the amount of points you gain/lose:

Code: Select all

if charA >= 10:
All of this works fine... however, is there a way to create events based on multiple characters stats?

like if "charA" and "charB" both have 10 points or more, an event would trigger.
However the event where "charA" has to have 10 points and "charB" 0 would not trigger.

Is this at all possible? How would I make that work if it is?
Thanks for any help! :)
Last edited by Elta on Sat Jun 08, 2019 7:10 pm, edited 1 time in total.

User avatar
Matalla
Veteran
Posts: 202
Joined: Wed Mar 06, 2019 6:22 pm
Completed: The Lost Smile
itch: matalla-interactive
Location: Spain
Contact:

Re: love meter event with more then one character.

#2 Post by Matalla » Sat Jun 08, 2019 6:44 pm

Just like you said

Code: Select all

if charA >= 10 and charB >= 10:
    # Here the event or a jump to it
If charB doesn't meet the requirement, it wouldn't execute de code below.
Comunidad Ren'Py en español (Discord)
Honest Critique

User avatar
Elta
Regular
Posts: 72
Joined: Sun Jun 02, 2019 6:28 pm
Tumblr: limitelta
Deviantart: limitelta
itch: limitelta
Contact:

Re: love meter event with more then one character.

#3 Post by Elta » Sat Jun 08, 2019 6:52 pm

Matalla wrote:
Sat Jun 08, 2019 6:44 pm
Just like you said

Code: Select all

if charA >= 10 and charB >= 10:
    # Here the event or a jump to it
If charB doesn't meet the requirement, it wouldn't execute de code below.
Oh! I'm so new to this coding, didn't realize I could put "and"! xD Thank you so so much!

So if I used:

Code: Select all

if charA >= 10 and charB >= 0:
    # Here the event or a jump to it
would that mean the event only happens if charB has 0 points (I guess I'm asking if the code requires the exact point value?)
Edit: Right now it played all three options even though both characters had 10 points. So the points have to be above the number to make it play I'm guessing.
Is there a way to specify a range of points? For example can you do something like this?

Code: Select all

if charA >= 10-20 and charB >= 0-4:
    # Here the event or a jump to it
Or specify the number must be lower then/equal too the number?

I really appreciate your help!

User avatar
Matalla
Veteran
Posts: 202
Joined: Wed Mar 06, 2019 6:22 pm
Completed: The Lost Smile
itch: matalla-interactive
Location: Spain
Contact:

Re: love meter event with more then one character.

#4 Post by Matalla » Sat Jun 08, 2019 7:07 pm

If you want to happen when is exactly 0 then

Code: Select all

if charA >= 10 and charB == 0:
There are several ways of coding ranges. Probably most of them a bit confusing at the stage you're now. The easiest way would be just combining several conditions.

Code: Select all

if (charA >= 10 and charA <=20) and (charB >= 0 and charB <= 4):
In this case, it would work also without the parenthesis, I just added them for clarity.

Really, almost all this you can do it using a little bit of logic and a basic understanding of the comparison operators in python. Check this and try to use them in a couple of examples and you're good.

https://www.tutorialspoint.com/python/p ... rators.htm
Comunidad Ren'Py en español (Discord)
Honest Critique

User avatar
Elta
Regular
Posts: 72
Joined: Sun Jun 02, 2019 6:28 pm
Tumblr: limitelta
Deviantart: limitelta
itch: limitelta
Contact:

Re: love meter event with more then one character.

#5 Post by Elta » Sat Jun 08, 2019 7:09 pm

Matalla wrote:
Sat Jun 08, 2019 7:07 pm
If you want to happen when is exactly 0 then

Code: Select all

if charA >= 10 and charB == 0:
There are several ways of coding ranges. Probably most of them a bit confusing at the stage you're now. The easiest way would be just combining several conditions.

Code: Select all

if (charA >= 10 and charA <=20) and (charB >= 0 and charB <= 4):
In this case, it would work also without the parenthesis, I just added them for clarity.

Really, almost all this you can do it using a little bit of logic and a basic understanding of the comparison operators in python. Check this and try to use them in a couple of examples and you're good.

https://www.tutorialspoint.com/python/p ... rators.htm
Thank you so much for your help once more, I never could have got this without you! 😃💕
I'll be sure to look though that link carefully! I'm glad to have that resource!

Post Reply

Who is online

Users browsing this forum: Bing [Bot], Google [Bot]