[Solved]Changing description to match numerical value

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
facadepapergirl
Regular
Posts: 46
Joined: Thu Jan 31, 2013 7:27 pm
Projects: Pokemon: Final Evolution; Galactic Lust Crisis
Contact:

[Solved]Changing description to match numerical value

#1 Post by facadepapergirl »

I'm trying to have a system where you can change certain values through various means. If you change these values, your description in game changes. I've included a small portion, as the rest is simply more numbers and another variable.

Code: Select all

$ chest = 0

$ chestlook = None

if chest = 0:
    $ chestlook = "flat, masculine chest"
if tits = 1:
    $ chestlook = "soft A-cups"
if tits = 2:
    $ chestlook = "round B-cups"
if tits = 3:
    $ chestlook = "hefty C-cups"
But when I try to run it, all I get is this for every line with the if statement:
�ソI'm sorry, but an uncaught exception occurred.

While running game code:
File "game\script.rpy", line 57, in script
SyntaxError: invalid syntax (script.rpy, line 57)

-- Full Traceback ------------------------------------------------------------

Full traceback:
File "C:\Program Files\renpy-6.14.1-sdk\renpy\execution.py", line 266, in run
File "C:\Program Files\renpy-6.14.1-sdk\renpy\ast.py", line 1394, in execute
File "C:\Program Files\renpy-6.14.1-sdk\renpy\python.py", line 1206, in py_eval
File "C:\Program Files\renpy-6.14.1-sdk\renpy\python.py", line 413, in py_compile
SyntaxError: invalid syntax (script.rpy, line 57)

Windows-7-6.1.7601-SP1
Ren'Py 6.14.1.366
A Ren'Py Game 0.0
What is wrong with that code, and how can I fix it?
Last edited by facadepapergirl on Sat Aug 17, 2013 10:40 pm, edited 1 time in total.

jw2pfd
Regular
Posts: 87
Joined: Tue Sep 18, 2012 9:55 pm
Location: DFW, TX, USA
Contact:

Re: Changing description to match numerical value

#2 Post by jw2pfd »

facadepapergirl wrote:I'm trying to have a system where you can change certain values through various means. If you change these values, your description in game changes. I've included a small portion, as the rest is simply more numbers and another variable.

But when I try to run it, all I get is this for every line with the if statement:
SyntaxError: invalid syntax (script.rpy, line 57)

What is wrong with that code, and how can I fix it?
There are two things going on here potentially. First off, when you want to check for equality in a conditional statement, it has to be a double equal sign '=='. This will be true for all of the if statements in your code. Also, I don't know the rest of your code, so I don't know if it's intentional or not for you to have a different variable name other than 'chest' after the first 'if' statement. You'll definitely want to change the equal signs though to double equal signs. Think of it this way, a single equal signs means to assign a value and a double equal sign is to check whether or not they are equal.

Code: Select all

$ chest = 0                               #<-- chest

$ chestlook = None

if chest == 0:                                       #<-- chest
    $ chestlook = "flat, masculine chest"
if tits == 1:                                          #<-- different variable name (on purpose?)
    $ chestlook = "soft A-cups"
if tits == 2:                                          #<-- different variable name
    $ chestlook = "round B-cups"
if tits == 3:                                          #<-- different variable name
    $ chestlook = "hefty C-cups"

User avatar
facadepapergirl
Regular
Posts: 46
Joined: Thu Jan 31, 2013 7:27 pm
Projects: Pokemon: Final Evolution; Galactic Lust Crisis
Contact:

Re: Changing description to match numerical value

#3 Post by facadepapergirl »

Sorry, I had changed tits to chest in case I offended people, but it seems that I got distracted and forgot to finish changing it out. So, the double = signs seems to be the answer to my problem. I'll try it tomorrow, and see how it works, though I think that it should be fine. Thank you very much.

Post Reply

Who is online

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