Invalid syntax error in a point based ending system

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
AmazingA
Newbie
Posts: 8
Joined: Thu Mar 08, 2018 10:53 pm
Projects: First Law of Thermodynamics
Soundcloud: Amazing A
Contact:

Invalid syntax error in a point based ending system

#1 Post by AmazingA »

I've been working on a VN and it has a point based ending system. I have seen and cross checked it, but I am getting an invalid syntax error. Here is the error file:
I'm sorry, but errors were detected in your script. Please correct the
errors listed below, and try again.


File "game/script.rpy", line 36: invalid syntax
practice points = 0
^


File "game/script.rpy", line 37: invalid syntax
happiness points = 0
^


File "game/script.rpy", line 38: invalid syntax
spirit satisfaction = 0
^


File "game/script.rpy", line 68: invalid syntax
happiness points += 1
^


File "game/script.rpy", line 115: invalid syntax
happiness points += 1
^


File "game/script.rpy", line 341: invalid syntax
happiness points -= 1
^


File "game/script.rpy", line 616: invalid syntax
spirit satisfaction += 1
^


File "game/script.rpy", line 620: invalid syntax
spirit satisfaction -= 1
^


File "game/script.rpy", line 775: invalid syntax
happiness points += 1
^


File "game/script.rpy", line 780: invalid syntax
happiness points -= 1
^


File "game/script.rpy", line 966: invalid syntax
practice points += 1
^


File "game/script.rpy", line 967: invalid syntax
spirit satisfaction +=1
^


File "game/script.rpy", line 972: invalid syntax
spirit satisfaction -= 1
^


Ren'Py Version: Ren'Py 6.99.14.1.3218
Sat Jun 02 10:44:16 2018

Here is some of the code where the errors are:

Code: Select all

init:
    python:
        def max_points(*values):
            return [ i for i, v in enumerate(values) if v == max(values) ]

    $ practice points = 0
    $ happiness points = 0
    $ spirit satisfaction = 0
    
menu:

         "Wake up.":
               $ happiness points += 1
               jump choice1_yes  

          "Nah, just a little bit more sleep.":
               jump choice1_no
menu:       
             
          "Invite him to sit and have breakfast.":
              $ happiness points += 1 
              jump choice2_yes  
     
          "Nah, he must've had food already.":
                jump choice2_no
(This is just some of the error code.)
Please help me fix these.
Thanks

Rayne
Newbie
Posts: 7
Joined: Mon May 28, 2018 9:46 pm
Contact:

Re: Invalid syntax error in a point based ending system

#2 Post by Rayne »

Variables can't have spaces in them. Use happiness_points, practice_points, etc.

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

Re: Invalid syntax error in a point based ending system

#3 Post by kivik »

I'm guessing you're new to programming - just to clarify something:

You'll see that in the Renpy language you can define images with spaces in them, and it may make you think that you can do that with variables. But images aren't actually variables at all, they're renpy specific objects utilising a hierarchical tagging system - and you define them all starting the line with the renpy specific keyword "image".

So the thing to remember is - variables can't have spaces (nor most symbols like -,.$%£@!* etc. Underscore is safe though as Rayne pointed out). Images can have spaces.

AmazingA
Newbie
Posts: 8
Joined: Thu Mar 08, 2018 10:53 pm
Projects: First Law of Thermodynamics
Soundcloud: Amazing A
Contact:

Re: Invalid syntax error in a point based ending system

#4 Post by AmazingA »

Thanks! I am new to programming (as you already guessed :oops: ) and this helped me a lot. I was stuck because of this bug. Thanks!

Post Reply

Who is online

Users browsing this forum: henne