Syntax Error with If 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
maggert
Newbie
Posts: 1
Joined: Wed Jun 21, 2017 10:42 pm
Tumblr: bloodknightrosalie
Contact:

Syntax Error with If statements

#1 Post by maggert »

I'm having a hard time creating a random household generator for a tabletop campaign I'm running. It's giving a syntax error for line 76 in my code (if abandoned = 1:) seen as below:

Code: Select all

menu:
    "Choose a town."
    
    "Fortree City":
        $townname = "FortreeCity"
        $roommatepossible = 1
        $religionpossible = 1
        $typepokemon1 = "Bug"
        $typepokemon2 = "Flying"
        $typepokemon3 = "Grass"
        jump startgen
        
    "No idea.":
        "Yeah, I'm not sure, either."
        jump generic
        
label startgen:

$abandoned = renpy.random.randint(0, 1)

if abandoned = 1:
    #Pairing numbers: Dating 1, Engaged 2, Married 3, Not 4-6 #
    $paired = renpy.random.randint(1, 6)
    if paired >= 4:
        $ singlekids = renpy.random.randint(0, 1)
        if singlekids = 1:
            $ numbersinglekids = renpy.random.randint(1, 3)
        else:
            $ numbersinglekids = 0
    else:
        $ singlekids = 0

User avatar
PyTom
Ren'Py Creator
Posts: 16096
Joined: Mon Feb 02, 2004 10:58 am
Completed: Moonlight Walks
Projects: Ren'Py
IRC Nick: renpytom
Github: renpytom
itch: renpytom
Location: Kings Park, NY
Contact:

Re: Syntax Error with If statements

#2 Post by PyTom »

Python uses = for assignment, == for comparison. So you'll want to write:

Code: Select all

if abandoned == 1:
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
Software > Drama • https://www.patreon.com/renpytom

Post Reply

Who is online

Users browsing this forum: No registered users