Page 1 of 2

Indentation Mismatch error

Posted: Wed Jul 18, 2012 1:47 am
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)

Re: Indentation Mismatch error

Posted: Wed Jul 18, 2012 2:22 am
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

Re: Indentation Mismatch error

Posted: Wed Jul 18, 2012 10:38 am
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

Re: Indentation Mismatch error

Posted: Wed Jul 18, 2012 12:30 pm
by PyTom
Ren'Py does care, however. It demands you use spaces, to prevent space-tab confusion.

Re: Indentation Mismatch error

Posted: Thu Apr 21, 2016 4:11 pm
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 :)

Re: Indentation Mismatch error

Posted: Thu Apr 21, 2016 5:03 pm
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.

Re: Indentation Mismatch error

Posted: Sun May 22, 2016 8:27 am
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

Re: Indentation Mismatch error

Posted: Sun May 22, 2016 8:56 am
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

Re: Indentation Mismatch error

Posted: Sun May 22, 2016 9:33 am
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?

Re: Indentation Mismatch error

Posted: Sun May 22, 2016 9:44 am
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

Re: Indentation Mismatch error

Posted: Sun May 22, 2016 10:59 am
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?

Re: Indentation Mismatch error

Posted: Sun May 22, 2016 12:09 pm
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?

Re: Indentation Mismatch error

Posted: Wed Feb 15, 2017 10:09 pm
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

Re: Indentation Mismatch error

Posted: Thu Jan 25, 2018 3:01 pm
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 :)

Re: Indentation Mismatch error

Posted: Thu Feb 22, 2018 5:41 am
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.