Question with < or > statements

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
AHAKuo
Regular
Posts: 41
Joined: Tue Feb 06, 2018 11:10 am
Projects: SoUnd Is ToxIc
Organization: AHAKuo
Tumblr: ahakuo
Deviantart: ahakuo
Contact:

Question with < or > statements

#1 Post by AHAKuo »

I have been trying to get this code to work, but it keeps telling me that it's an invalid syntax. I just needed an image to be different everytime the relationship changed between two characters. The variables zandra_relationship and blue_relationship are values that have been defined, but the code won't work.

I would really love the help. Here's the code I'm trying to use:
if zandra_relationship > blue_relationship:
scene schoolclass3d2morningpurple
elif zandra_relationship < blue_relationship:
scene schoolclass3d2morningblue
elif zandra_relationship = blue_relationship:
scene schoolclass3d2morningred
with dissolve
Working on:

Image

chocochino
Newbie
Posts: 12
Joined: Wed Jan 24, 2018 3:29 am
Projects: An Edelweiss' Resolve
Tumblr: choc-chino
Github: chocochino
Soundcloud: chocochino
itch: chocochino
Location: Indonesia
Contact:

Re: Question with < or > statements

#2 Post by chocochino »

You need == for an a equals b comparison! This sign = is used to assign value to variables, not to compare variable's values. Also, mind your tabs ^^

kivik
Miko-Class Veteran
Posts: 786
Joined: Fri Jun 24, 2016 5:58 pm
Contact:

Re: Question with < or > statements

#3 Post by kivik »

What chocochino have said.

But also, in your situation, you don't even need to test the last condition, because the only possible remaining condition after you tested greater than and less than is equal to, so you can in fact do:

Code: Select all

if zandra_relationship > blue_relationship:
    scene schoolclass3d2morningpurple
elif zandra_relationship < blue_relationship:
    scene schoolclass3d2morningblue
else:
    scene schoolclass3d2morningred
with dissolve
Else captures all remaining possibilities, so in this scenario can be used. But also make sure you remember to use == for comparison, and = for assignment.

User avatar
AHAKuo
Regular
Posts: 41
Joined: Tue Feb 06, 2018 11:10 am
Projects: SoUnd Is ToxIc
Organization: AHAKuo
Tumblr: ahakuo
Deviantart: ahakuo
Contact:

Re: Question with < or > statements

#4 Post by AHAKuo »

kivik wrote: Sat May 19, 2018 6:19 am What chocochino have said.

But also, in your situation, you don't even need to test the last condition, because the only possible remaining condition after you tested greater than and less than is equal to, so you can in fact do:

Code: Select all

if zandra_relationship > blue_relationship:
    scene schoolclass3d2morningpurple
elif zandra_relationship < blue_relationship:
    scene schoolclass3d2morningblue
else:
    scene schoolclass3d2morningred
with dissolve
Else captures all remaining possibilities, so in this scenario can be used. But also make sure you remember to use == for comparison, and = for assignment.
Thanks so much! It works perfectly! :D I can't thank you enough <3
Working on:

Image

Post Reply

Who is online

Users browsing this forum: haitai, Semrush [Bot]