Page 1 of 1

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

Posted: Sat Jun 08, 2019 6:16 pm
by Elta
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! :)

Re: love meter event with more then one character.

Posted: Sat Jun 08, 2019 6:44 pm
by Matalla
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.

Re: love meter event with more then one character.

Posted: Sat Jun 08, 2019 6:52 pm
by Elta
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!

Re: love meter event with more then one character.

Posted: Sat Jun 08, 2019 7:07 pm
by Matalla
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

Re: love meter event with more then one character.

Posted: Sat Jun 08, 2019 7:09 pm
by Elta
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!