Indentation Mismatch error

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.
Message
Author
Starky
Newbie
Posts: 1
Joined: Wed Jul 18, 2012 1:29 am
Contact:

Indentation Mismatch error

#1 Post by Starky »

I keep getting an error called "Indentation Mismatch" that occurs on the same line as my 'Return' code.
Bare in mind this is my very first Ren'Py game, and I'm an absolute noob at Python, but I do wish to learn so I figure you guys can help out right with any questions I have. Don't worry, I won't ask loads.
But I don't really understand this error, I don't have any indentation on the return code, and when I do, I still get the same error, I've provided a screen shot, does anyone know what could be wrong? (Note: This occured when I was making a choice menu)
Attachments
error.png

User avatar
Michiyo6918
Veteran
Posts: 262
Joined: Fri Nov 11, 2011 12:26 am
Projects: ╮(╯▽╰)╭
Location: Look behind you
Contact:

Re: Indentation Mismatch error

#2 Post by Michiyo6918 »

First, welcome to Ren'py and LSF!

Second, this is a usual error that frequently occurs to beginner. I used to get this all the time, don't worry.
I don't have any indentation on the return code
What do you mean by this? Does it mean you don't have any space in front of the return code? Like this?:

Code: Select all

return
If it looks like that then you're doing it wrong. There have to be 4 spaces of indentation in front of the return code like this:

Code: Select all

    return
If the one I mentioned above is not your problem then I can give you a small example of how the indentation should look like in Ren'py when you're using menu choice:

Code: Select all

label start:
    "Dialog go here."
    menu:
        "Choice 1":
            "Dialog again."
        "Choice 2":
            "Dialog."

    return
If you're still having any problem, feel free to post your question and good luck on your project! :D
Tumblr | DA | Honest Critique
“如果那个人是神。
他想渎神。
——【黑匣子】”

User avatar
SusanTheCat
Miko-Class Veteran
Posts: 952
Joined: Mon Dec 13, 2010 9:30 am
Location: New Brunswick, Canada
Contact:

Re: Indentation Mismatch error

#3 Post by SusanTheCat »

Another thing to remember is that "tabs" are not the same as "spaces". Python doesn't care what you use, as long as you are consistent. http://enjoydoingitwrong.wordpress.com/ ... in-python/

Susan
" It's not at all important to get it right the first time. It's vitally important to get it right the last time. "
— Andrew Hunt and David Thomas

User avatar
PyTom
Ren'Py Creator
Posts: 16088
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: Indentation Mismatch error

#4 Post by PyTom »

Ren'Py does care, however. It demands you use spaces, to prevent space-tab confusion.
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

Crayona
Newbie
Posts: 1
Joined: Thu Apr 21, 2016 4:01 pm
Contact:

Re: Indentation Mismatch error

#5 Post by Crayona »

Hello !
I'm a newbe in this forum and please excused my english because I'm french, and as the cliché said , the french ar'nt very good in foreign language ^^"
I've a problem with my script and ren'py write ' indentation mismatch' I don't understand this ... Could you help me please ?
hear is my script:
c" Ce cours s'annonce plus long et pénible que jamais."
c" Quand soudain..."
show Vincent at left
c" Je le vois. Encore en retard, c'est son coté ''Bad Boy'' ... Il est magnifique, je l'aime tellement."
c" Il file à sa place et le cours continue."

menu:

"Le fixer du regard"
jump f:

"Continuer à suivre le cours normalement et crayoner"
jump c:


label f:

ps" Crayona! De qui te moques-tu ? Tu n'as rien écrit depuis 20 bonnes minutes. Tu as le droit d'etre amoureuse de Vincent mais à la récré s'il te plait!"
c" Mais Madame... Je...Euh...Je..."
c" *J'entends des gloussements."
c"Une fois de plus je suis humiliée."
show Crayona triste
c" Adieu ma romance..."


".:. Bad Ending."
return


label c:

show Crayona triste

(hear come the pb) c" Ce cours sur le Mercosur et l'ALENA est vraiment loin d'etre passionnant. Heureusement, je suis Crayona ! Mon art me sauve de cet ennui. Crayonnons, Crayonnons!!!"

show bg dessin2


jump suite

label suite:



c" Enfin la récré!"


Thanks you in advances :)

User avatar
Donmai
Eileen-Class Veteran
Posts: 1958
Joined: Sun Jun 10, 2012 1:45 am
Completed: Toire No Hanako, Li'l Red [NaNoRenO 2013], The One in LOVE [NaNoRenO 2014], Running Blade [NaNoRenO 2016], The Other Question, To The Girl With Sunflowers
Projects: Slumberland
Location: Brazil
Contact:

Re: Indentation Mismatch error

#6 Post by Donmai »

You should post your code between CODE tags, so the indentation is preserved. Click on the Code button on the header while you're editing your post, and paste your code between the two CODE tags that will apear.
Image
No, sorry! You must be mistaking me for someone else.
TOIRE NO HANAKO (A Story About Fear)

User avatar
KurisuCrush
Newbie
Posts: 7
Joined: Sun May 22, 2016 8:21 am
Contact:

Re: Indentation Mismatch error

#7 Post by KurisuCrush »

Hi, I have the same problem:

Code: Select all

# Vous pouvez placer le script de votre jeu dans ce fichier.

# Déclarez sous cette ligne les images, avec l'instruction 'image'
# ex: image eileen heureuse = "eileen_heureuse.png"
image kurisu = "images/mood0.png"
image bgg = "images/steinsgate.jpg"

# Déclarez les personnages utilisés dans le jeu.
define s = Character('shippy', color='#aa4933')
define p = Character('protagoniste', color='#aa4933')    
# Le jeu commence ici
label start:
    scene bgg
    show kurisu
    play music "soundtrack/ost1.mp3"
    window show
    
    $ s = "?????"
    
image kurisu animated:
      "images/mood0.png"
      pause .5
      "images/mood0a.png"
      pause .5
      "images/mood0b.png"
      repeat 2.5
    s "Fait attention! C'est dangereuse ici!"
    s "Pourquoi tu est ici..? Qui-es tu?"
    p "Je me rappelé pas mon prénom.."
    s "...ça c'est pas bien! Viens avec mois!"
 
image kurisu animated:
      "images/mood1.png"
      pause .5
      "images/mood1a.png"
      pause .5
      "images/mood1b.png"
      repeat 2.5
    $ s = "Kurisu"
    s "Je m’appelle Kurisu"

    stop music fadeout 2.0
    
    return

User avatar
korova
Veteran
Posts: 217
Joined: Sat Jun 27, 2009 5:15 pm
Completed: Ivy, Chocolate, Time, Clair Obscur
Projects: Writing exercises, The House [Nano18]
Tumblr: korova08
itch: korova
Location: Normandie, France
Contact:

Re: Indentation Mismatch error

#8 Post by korova »

You should declare your images before the label start. (Il faut déclarer les images avant le label start, puis les afficher)

You should have the same number of spaces at the beginning of all you lines, which is clearly not the case everytime you declare an image. Indentation has to be consistent (Il y a décalage, certaines lignes ont plus d'espaces que d'autres en début de ligne, ce nombre doit toujours être le même)

Try this code (proposition de correction de code)

Code: Select all

# Vous pouvez placer le script de votre jeu dans ce fichier.

# Déclarez sous cette ligne les images, avec l'instruction 'image'
# ex: image eileen heureuse = "eileen_heureuse.png"
image kurisu = "images/mood0.png"

image kurisu animated1:
    "images/mood0.png"
    pause .5
    "images/mood0a.png"
    pause .5
    "images/mood0b.png"
    repeat 2.5

image kurisu animated2:
    "images/mood1.png"
    pause .5
    "images/mood1a.png"
    pause .5
    "images/mood1b.png"
    repeat 2.5

image bgg = "images/steinsgate.jpg"

# Déclarez les personnages utilisés dans le jeu.
default shippy = "?????"
define s = Character('[shippy]', color='#aa4933')
default protagoniste = "protagoniste"
define p = Character('[protagoniste]', color='#aa4933')   
# Le jeu commence ici
label start:
    scene bgg
    show kurisu
    play music "soundtrack/ost1.mp3"
    window show  

    show kurisu animated1
    s "Fait attention! C'est dangereux ici !"
    s "Pourquoi tu es ici..? Qui es-tu?"
    p "Je ne me rappelle pas mon prénom.."
    s "...ça c'est pas bien ! Viens avec moi !"
 

    show kurisu animated2
    $ shippy = "Kurisu"
    s "Je m’appelle Kurisu"

    stop music fadeout 2.0
   
    return

User avatar
KurisuCrush
Newbie
Posts: 7
Joined: Sun May 22, 2016 8:21 am
Contact:

Re: Indentation Mismatch error

#9 Post by KurisuCrush »

Ah okay thanks for the help! But I have another question, how I can set the character animation until the reader finish to read and click for the next phrase?

User avatar
korova
Veteran
Posts: 217
Joined: Sat Jun 27, 2009 5:15 pm
Completed: Ivy, Chocolate, Time, Clair Obscur
Projects: Writing exercises, The House [Nano18]
Tumblr: korova08
itch: korova
Location: Normandie, France
Contact:

Re: Indentation Mismatch error

#10 Post by korova »

I'm not really sure I understand what you want to achieve here.
What about you replace the animated image by a static one when you want to stop the animation ?

By the way I realize there is an error in your image definition code.
the instruction "repeat" is followed by the number of times you want the instruction to repeat. So 2.5 won't work.
If you want it to repeat forever, just put repeat, with no number.

maybe you were trying to do this ?

Code: Select all

image kurisu animated2:
    "images/mood1.png"
    pause .5
    "images/mood1a.png"
    pause .5
    "images/mood1b.png"
    pause 2.5
    repeat

User avatar
Donmai
Eileen-Class Veteran
Posts: 1958
Joined: Sun Jun 10, 2012 1:45 am
Completed: Toire No Hanako, Li'l Red [NaNoRenO 2013], The One in LOVE [NaNoRenO 2014], Running Blade [NaNoRenO 2016], The Other Question, To The Girl With Sunflowers
Projects: Slumberland
Location: Brazil
Contact:

Re: Indentation Mismatch error

#11 Post by Donmai »

korova wrote:I'm not really sure I understand what you want to achieve here.
Maybe KurisuCrush is talking about the click-to-continue icon?
Image
No, sorry! You must be mistaking me for someone else.
TOIRE NO HANAKO (A Story About Fear)

User avatar
KurisuCrush
Newbie
Posts: 7
Joined: Sun May 22, 2016 8:21 am
Contact:

Re: Indentation Mismatch error

#12 Post by KurisuCrush »

Nothing, I found the problem alone, sorry for my bad english!:D
Anyway last answer, there are a method to change the main menu background after a bad end?

Deaddisc
Newbie
Posts: 4
Joined: Sun Feb 12, 2017 9:07 am
Contact:

Re: Indentation Mismatch error

#13 Post by Deaddisc »

# Player Gender -------- Player Gender -------- Player Gender -------- Player Gender -------- Player Gender -------- Player Gender --------
label start:

jump Mainstory

label PlayerSelecter:

"Please select gender and name"

menu:

"Male":
jump PlayerGenderMale


"Female":
jump PlayerGenderFemale





label PlayerGenderMale:

$ player_gender = "Male"

if player_gender = "Male":

image Player_Image = "PlayerMaleImage.png"
#If gender is male the character image should be male.

show Player_image #ERROR HERE ---

"this should be a Male Image"

jump Endgame

label PlayerGenderFemale:

$ player_gender = "Female"

if player_gender = "Female":

image Player_Image = "PlayerFemaleImage.png"
#If gender is female the character image should be female.

show Player_image

"this should be a Female Image"

jump Endgame







# PlayerName -------- PlayerName -------- PlayerName -------- PlayerName -------- PlayerName -------- PlayerName -------- PlayerName --------

label PlayerName:

$ player_name = ""


$ player_name = renpy.input("What is your name")
$ player_name = player_name.strip()

if player_name == "":
$player_name = "Hayden"


label Endgame:

"the end"

# This ends the game.
return


for some reason i get a missmatch on: show Player_image tryed to look around and cant find anything that can help me and if you guys have a better way on how to make a gender selecter im all ears

Kuku
Newbie
Posts: 1
Joined: Thu Jan 25, 2018 2:54 pm
Contact:

Re: Indentation Mismatch error

#14 Post by Kuku »

Hi! I only started trying to make a visual novel on ren'py... There are so many errors and everything is so confusing... I'm using windows 10 and I'm not too sure what I'm doing with the code but it is written that:
-Line 7 is indented, but but the preceding statement does not expect a block
-(Same thing as before but with line 13)

Here is the script so far:

label start:

image Apartment = "AC.png"

scene Apartment

$ player_name = ""
$ player_name = renpy.input("Enter name here.")
$ player_name = player_name.strip()

scene dissolve

return








Thanks :)

JimmyFrost
Regular
Posts: 30
Joined: Fri May 01, 2015 9:46 am
Projects: TOWER
Location: United States
Contact:

Re: Indentation Mismatch error

#15 Post by JimmyFrost »

Hello, this pertains to my current issue with an attempt on doing something ambitious. The offending code is on line 33, but I feel like I'm riding on false presumptions.

Code: Select all

init python:
    class Actor(object):
    """Characters built specifically to fight battles in-game. . .
    Args:
        Actor(str):name of character
        Active(bool):
        Atk(int):
        Def(int):
        Mat(int):
        Mdf(int):
        HP(int):
        MP(int):
        SP(int):
        magic_set(dict):
        demon_set(dict):
        personality(str):
    """
    def __init__(self, Actor"", Active=True, Atk=0, Def=0, Mat=0, Mdf=0, HP=0, MP=0, SP=0, magic_set[], demon_set[], personality""):
            self.Actor = Actor
            self.Active = Active
            self.Atk = Atk
            self.Def = Def
            self.Mat = Mat
            self.Mdf = Mdf
            self.HP = HP
            self.MP = MP
            self.SP = SP
            self.magic_set = magic_set
            self.demon_set = demon_set
            self.personality = personality
            self.status  = [self.Atk, self.Def, self.Mat, self.Mdf, self.HP, self.MP, self.SP]
       
       def magic_register(self, magic_name):
           self.magic_set.append(magic_name)
       def demon_register(self, demon_name):
           self.demon_set.append(demon_name)
           
       def normalize_status(self):
           print "Normalizing status. Please wait. . ."
           for index, value in enumerate(self.status):
               if value <= 0:
                   self.status[index] = 0
               return self.status
Should the indentation be deeper? Because the error still remains when I make all the def statements line up.
"If hard work hasn't hurt anyone, then why is there worker's comp?"

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Kocker