Syntax Error, Persona-like social link 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
User avatar
Westeford
Regular
Posts: 151
Joined: Mon Jun 19, 2017 4:43 pm
Completed: 12 Hours to Die
Projects: Project Premonition
itch: westeford
Location: United States
Contact:

Syntax Error, Persona-like social link system

#1 Post by Westeford »

I'm trying to replicate the social link system that is used in Persona 3 and Persona 4. The player chooses who to hang out with, a scene plays, after the scene time passes and the player goes home. The scenes always appear in order. (Example: rank 1 always plays before rank 2.)
Here's an example of a social link.
[youtube]https://www.youtube.com/watch?v=hjl59hB ... hom%C3%A9t[/youtube]

Any suggestions would be appreciated.

script.rpy

Code: Select all

label start:
    $ librank = 0
    #This sets librank's value to 0.
label morning:
    scene cafeteria
    "Where shall I go today?"
menu:
    "How shall I spend my morning."
#choose one of the two choices.
#Alone has no problems
    "Alone":
        scene myroom
        "I spent time organizing my notes."
#What I want Library to do is to jump to the library label in sociallinks.rpy 
    "Library":
        jump library
    
label afternoon:
    "Now what?"
#I repeat the previous step so that I can test if the social link ranks stack.     
menu:
    "How shall I spend my afternoon."
    
    "Alone":
        scene myroom
        "I spent time organizing my notes."
    
    "Library":
        jump library
        
label evening:
    "now what?"
    
menu:
    "How shall I spend my evening."
    
    "Alone":
        scene myroom
        "I spent time organizing my notes."
    
    "Library":
        jump library
      
label done:
    "We're done!"

    return
sociallinks.rpy

Code: Select all

#Social Links
#When the player chooses library, it jumps to the library label. Then it should check the librank. if it's 1 then it should jump to the librank1 label. 2 then it jumps to librank 2. If 0 then it should jump down to the librank0 label.
label library:
    if librank = 1:
        jump librank1
    elif librank = 2:
        jump librank2
    else:
        jump librank0

#After jumping down to one of the labels below, the scene associated with the right label should play then assign librank a new value. Then I would like it to return to script.rpy and play the scene after the chosen choice.
label librank0:
    "Yay rank 1"
    $ librank = 1
    
label librank1:
    "Rank 2"
    $ librank = 2
    
label librank2:
    "Rank 3"
    $ librank = 3
Here's the error that comes after clicking Library

Code: Select all

I'm sorry, but an uncaught exception occurred.

While running game code:
  File "game/sociallinks.rpy", line 4, in script
    if librank = 1:
SyntaxError: invalid syntax (game/sociallinks.rpy, line 4)

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

Full traceback:
  File "game/sociallinks.rpy", line 4, in script
    if librank = 1:
  File "C:\Users\Wesley\Desktop\Renpy\renpy-6.99.3-sdk\renpy\ast.py", line 1656, in execute
    if renpy.python.py_eval(condition):
  File "C:\Users\Wesley\Desktop\Renpy\renpy-6.99.3-sdk\renpy\python.py", line 1748, in py_eval
    code = py_compile(code, 'eval')
  File "C:\Users\Wesley\Desktop\Renpy\renpy-6.99.3-sdk\renpy\python.py", line 584, in py_compile
    raise e
SyntaxError: invalid syntax (game/sociallinks.rpy, line 4)

Windows-8-6.2.9200
Ren'Py 6.99.12.4.2187
SocialLinks 1.0
Attachments
SocialLinks.zip
Here's the small game that tests the system.
(580.07 KiB) Downloaded 33 times

Human Bolt Diary
Regular
Posts: 111
Joined: Fri Oct 11, 2013 12:46 am
Contact:

Re: Syntax Error, Persona-like social link system

#2 Post by Human Bolt Diary »

Code: Select all

    if librank = 1:
should be:

Code: Select all

if librank == 1:
Equality checking uses "==".

User avatar
Westeford
Regular
Posts: 151
Joined: Mon Jun 19, 2017 4:43 pm
Completed: 12 Hours to Die
Projects: Project Premonition
itch: westeford
Location: United States
Contact:

Re: Syntax Error, Persona-like social link system

#3 Post by Westeford »

Thank you, I feel silly now.

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot]